Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 90444 invoked from network); 20 Jul 2006 19:17:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Jul 2006 19:17:45 -0000 Received: (qmail 41083 invoked by uid 500); 20 Jul 2006 14:40:47 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 41035 invoked by uid 500); 20 Jul 2006 14:40:47 -0000 Mailing-List: contact harmony-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-dev@incubator.apache.org Received: (qmail 40985 invoked by uid 99); 20 Jul 2006 14:40:46 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Jul 2006 07:40:46 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of george.c.harley@googlemail.com designates 64.233.182.188 as permitted sender) Received: from [64.233.182.188] (HELO nf-out-0910.google.com) (64.233.182.188) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Jul 2006 07:40:45 -0700 Received: by nf-out-0910.google.com with SMTP id x4so589061nfb for ; Thu, 20 Jul 2006 07:40:23 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=googlemail.com; h=received:message-id:date:from:reply-to:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; b=DX3WUlbmUGuFnMlhJoWhoLBJUoHw/HkfSl7MRmhgnjCNpwC2ER2iKT9/LAgQ7RjRtSFjwCf/XRCHMGn/JQdfrOka5e1gzWExPm1akOF5rjIDMz5L2IY5VJA3JBZ6VQ+hgPzNCpUkgBtCJNkAVGnVzXJDMNC1wJW4siKr42bULl4= Received: by 10.48.80.20 with SMTP id d20mr563763nfb; Thu, 20 Jul 2006 07:40:23 -0700 (PDT) Received: from ?9.20.183.73? ( [195.212.29.83]) by mx.gmail.com with ESMTP id r34sm716320nfc.2006.07.20.07.40.22; Thu, 20 Jul 2006 07:40:22 -0700 (PDT) Message-ID: <44BF95C7.3090000@googlemail.com> Date: Thu, 20 Jul 2006 15:40:07 +0100 From: George Harley Reply-To: harmony-dev@incubator.apache.org User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) MIME-Version: 1.0 To: harmony-dev@incubator.apache.org Subject: Re: [classlib] Testing conventions - a proposal References: <44ABB451.30806@googlemail.com> <44B75E41.7020901@googlemail.com> <44BDCE12.4050303@gmail.com> <44BE0541.1050507@googlemail.com> <44BEF3A0.7000901@gmail.com> <44BF49C0.1020502@googlemail.com> <2c9597b90607200514l49051abcpa8962f98868ae038@mail.gmail.com> In-Reply-To: <2c9597b90607200514l49051abcpa8962f98868ae038@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Alexei Zakharov wrote: > George, > > I remember my past experience with BeanShell - I was trying to create > the custom BeanShell task for ant 1.6.1. I can't say I haven't > succeeded. But I remember this as a rather unpleasant experience. At > that time BeanShell appeared to me as a not very well tested > framework. Please don't throw rocks on me now, I am just talking about > my old impressions. Probably BeanShell has become better since then. > Hi Alexei, No rocks. I promise :-) > But... Do we really need BS here? Why can't we manage everything from > build.xml without extra testng.xml files? I mean something like this: > > > > > > > > > > > > > > > > > classpath="${jdk15.testng.jar}"/> > outputdir="${testng.report.dir}" > groups="${groups.included}" > excludedGroups="${groups.excluded}"> > > > > > Does this make sense? > > Thanks, Yes, that makes sense and if it gives the degree of control that we need then I would be all for it. The simpler the better. It looks like you are using an "os.any" group for those test methods (the majority) which may be run anywhere. That's a different approach to what I have been doing. I have been thinking more along the lines of avoiding the creation of groups that cover the majority of tests and trying to focus on groups that identify those "edge cases" like platform-specific, temporarily broken, temporarily broken on platform "os.blah" etc. This means my tests that are "run anywhere" and are "public api" type (as opposed to being specific to the Harmony implementation) are just annotated with "@Test". I guess that the equivalent in your scheme would be annotated as "@Test(groups = {"os.any", "type.api"})" ? If I have inferred correct from your Ant fragment then I think it means requiring more information on the annotations. I'm not throwing rocks at that idea (remember my promise ?), just trying to draw out the differences in our approaches. When I get a chance I will try and explore your idea further. I really appreciate your input here. Best regards, George > > 2006/7/20, George Harley : >> Richard Liang wrote: >> > >> > >> > George Harley wrote: >> >> Richard Liang wrote: >> >>> >> >>> >> >>> George Harley wrote: >> >>>> Hi, >> >>>> >> >>>> If annotations were to be used to help us categorise tests in order >> >>>> to simplify the definition of test configurations - what's included >> >>>> and excluded etc - then a core set of annotations would need to be >> >>>> agreed by the project. Consider the possibilities that the TestNG >> >>>> "@Test" annotation offers us in this respect. >> >>>> >> >>>> First, if a test method was identified as being broken and needed >> >>>> to be excluded from all test runs while awaiting investigation then >> >>>> it would be a simple matter of setting its enabled field like this: >> >>>> >> >>>> @Test(enabled=false) >> >>>> public void myTest() { >> >>>> ... >> >>>> } >> >>>> >> >>>> Temporarily disabling a test method in this way means that it can >> >>>> be left in its original class and we do not have to refer to it in >> >>>> any suite configuration (e.g. in the suite xml file). >> >>>> >> >>>> If a test method was identified as being broken on a specific >> >>>> platform then we could make use of the groups field of the "@Test" >> >>>> type by making the method a member of a group that identifies its >> >>>> predicament. Something like this: >> >>>> >> >>>> @Test(groups={"state.broken.win.IA32"}) >> >>>> public void myOtherTest() { >> >>>> ... >> >>>> } >> >>>> >> >>>> The configuration for running tests on Windows would then >> >>>> specifically exclude any test method (or class) that was a member >> >>>> of that group. >> >>>> >> >>>> Making a test method or type a member of a well-known group >> >>>> (well-known in the sense that the name and meaning has been agreed >> >>>> within the project) is essentially adding some descriptive >> >>>> attributes to the test. Like adjectives (the groups) and nouns (the >> >>>> tests) in the English language. To take another example, if there >> >>>> was a test class that contained methods only intended to be run on >> >>>> Windows and that were all specific to Harmony (i.e. not API tests) >> >>>> then one could envisage the following kind of annotation: >> >>>> >> >>>> >> >>>> @Test(groups={"type.impl", "os.win.IA32"}) >> >>>> public class MyTestClass { >> >>>> >> >>>> public void testOne() { >> >>>> ... >> >>>> } >> >>>> >> >>>> public void testTwo() { >> >>>> ... >> >>>> } >> >>>> >> >>>> @Test(enabled=false) >> >>>> public void brokenTest() { >> >>>> ... >> >>>> } >> >>>> } >> >>>> >> >>>> Here the annotation on MyTestClass applies to all of its test >> methods. >> >>>> >> >>>> So what are the well-known TestNG groups that we could define for >> >>>> use inside Harmony ? Here are some of my initial thoughts: >> >>>> >> >>>> >> >>>> * type.impl -- tests that are specific to Harmony >> >>>> >> >>>> * state.broken. -- tests bust on a specific platform >> >>>> >> >>>> * state.broken -- tests broken on every platform but we want to >> >>>> decide whether or not to run from our suite configuration >> >>>> >> >>>> * os. -- tests that are to be run only on the >> >>>> specified platform (a test could be member of more than one of >> these) >> >>>> >> >>>> >> >>>> What does everyone else think ? Does such a scheme sound >> reasonable ? >> >>>> >> >>> Just one question: What's the default test annotation? I mean the >> >>> successful api tests which will be run on every platform. Thanks >> a lot. >> >>> >> >>> Best regards, >> >>> Richard >> >> >> >> Hi Richard, >> >> >> >> I think that just the basic @Test annotation on its own will suffice. >> >> Any better suggestions are welcome. >> >> >> > Just thinking about how to filter out the target test groups :-) >> > >> > I tried to use the following groups to define the win.IA32 API tests, >> > but it seems that the tests with the default annotation @Test cannot >> > be selected. Do I miss anything? Thanks a lot. >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > The groups I defined: >> > @Test >> > @Test(groups={"os.win.IA32"}) >> > @Test(groups={"os.win.IA32", "state.broken.win.IA32"}) >> > @Test(groups={"type.impl"}) >> > @Test(groups={"state.broken"}) >> > @Test(groups={"os.linux.IA32"}) >> > @Test(groups={"state.broken.linux.IA32"}) >> > >> > Best regards, >> > Richard. >> >> Hi Richard, >> >> Infuriating isn't it ? >> >> The approach I have adopted so far is to aim for a single testng.xml >> file per module that could be used for all platforms that we run tests >> on. The thought of multiple testng.xml files for each module, with each >> XML file including platform-specific data duplicated across the files >> (save for a few platform identifiers) seemed less than optimal. >> >> So how do we arrive at this single testng.xml file with awareness of its >> runtime platform ? And how can that knowledge be applied in the file to >> filter just the particular test groups that we want ? Well, the approach >> that seems to work best for me so far is to use the make use of some >> BeanShell script in which we can detect the platform id as a system >> property and then use that inside some pretty straightforward >> Java/BeanShell code to select precisely the groups we want to run in a >> particular test. >> >> For example, in the following Ant fragment we use the testng task to >> launch the tests pointing at a specific testng.xml file >> (testng-with-beanshell.xml) and also setting the platform identifier as >> a system property hy.platform. In real life the value used to set the >> notional "hy.platform" property would be some agreed Ant property using >> a project-wide means of agreeing platform identities ... >> >> >> >> >> >> >> >> > includes="testng-with-beanshell.xml"/> >> > includes="**/*Test.class" /> >> >> >> >> The testng-with-beanshell.xml file contains a suite with several tests >> defined. Let's consider just the test that will run all of the API tests >> specific to our current platform (I think that this is what you want to >> run in your setup)... >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> There is some simple experimental code that I have omitted here (my >> apples.TestUtils class) that does some simple pattern matching stuff. >> Originally the code in the static "matchesAnyGroup" method was just >> defined in the CDATA script block as a BeanShell function. I just moved >> it into a separate Java class because I saw some reuse opportunity. >> Likewise the code to set the "platform" string variable could be split >> out into a static TestUtils method called getPlatform(). >> >> Anyway, the point I guess that I am trying to make here is that it is >> possible in TestNG to select the methods to test dynamically using a >> little bit of scripting that (a) gives us a lot more power than the >> include/exclude technique and (b) will work the same across every >> platform we test on. Because BeanShell allows us to instantiate and use >> Java objects of any type on the classpath then the possibility of using >> more than just group membership to decide on tests to run becomes >> available to us. Please refer to the TestNG documentation for more on >> the capabilities of BeanShell and the TestNG API. I had never heard of >> it before never mind used it but still managed to get stuff working in a >> relatively short space of time. >> >> I hope this helps. Maybe I need to write a page on the wiki or >> something ? >> >> Best regards, >> George >> >> >> >> >> Best regards, >> >> George >> >> >> >> >> >> >> >>>> Thanks for reading this far. >> >>>> >> >>>> Best regards, >> >>>> George >> >>>> >> >>>> >> >>>> >> >>>> George Harley wrote: >> >>>>> Hi, >> >>>>> >> >>>>> Just seen Tim's note on test support classes and it really caught >> >>>>> my attention as I have been mulling over this issue for a little >> >>>>> while now. I think that it is a good time for us to return to the >> >>>>> topic of class library test layouts. >> >>>>> >> >>>>> The current proposal [1] sets out to segment our different types >> >>>>> of test by placing them in different file locations. After looking >> >>>>> at the recent changes to the LUNI module tests (where the layout >> >>>>> guidelines were applied) I have a real concern that there are >> >>>>> serious problems with this approach. We have started down a track >> >>>>> of just continually growing the number of test source folders as >> >>>>> new categories of test are identified and IMHO that is going to >> >>>>> bring complexity and maintenance issues with these tests. >> >>>>> >> >>>>> Consider the dimensions of tests that we have ... >> >>>>> >> >>>>> API >> >>>>> Harmony-specific >> >>>>> Platform-specific >> >>>>> Run on classpath >> >>>>> Run on bootclasspath >> >>>>> Behaves different between Harmony and RI >> >>>>> Stress >> >>>>> ...and so on... >> >>>>> >> >>>>> >> >>>>> If you weigh up all of the different possible permutations and >> >>>>> then consider that the above list is highly likely to be extended >> >>>>> as things progress it is obvious that we are eventually heading >> >>>>> for large amounts of related test code scattered or possibly >> >>>>> duplicated across numerous "hard wired" source directories. How >> >>>>> maintainable is that going to be ? >> >>>>> >> >>>>> If we want to run different tests in different configurations then >> >>>>> IMHO we need to be thinking a whole lot smarter. We need to be >> >>>>> thinking about keeping tests for specific areas of functionality >> >>>>> together (thus easing maintenance); we need something quick and >> >>>>> simple to re-configure if necessary (pushing whole directories of >> >>>>> files around the place does not seem a particularly lightweight >> >>>>> approach); and something that is not going to potentially mess up >> >>>>> contributed patches when the file they patch is found to have been >> >>>>> recently pushed from source folder A to B. >> >>>>> >> >>>>> To connect into another recent thread, there have been some posts >> >>>>> lately about handling some test methods that fail on Harmony and >> >>>>> have meant that entire test case classes have been excluded from >> >>>>> our test runs. I have also been noticing some API test methods >> >>>>> that pass fine on Harmony but fail when run against the RI. Are >> >>>>> the different behaviours down to errors in the Harmony >> >>>>> implementation ? An error in the RI implementation ? A bug in the >> >>>>> RI Javadoc ? Only after some investigation has been carried out do >> >>>>> we know for sure. That takes time. What do we do with the test >> >>>>> methods in the meantime ? Do we push them round the file system >> >>>>> into yet another new source folder ? IMHO we need a testing >> >>>>> strategy that enables such "problem" methods to be tracked easily >> >>>>> without disruption to the rest of the other tests. >> >>>>> >> >>>>> A couple of weeks ago I mentioned that the TestNG framework [2] >> >>>>> seemed like a reasonably good way of allowing us to both group >> >>>>> together different kinds of tests and permit the exclusion of >> >>>>> individual tests/groups of tests [3]. I would like to strongly >> >>>>> propose that we consider using TestNG as a means of providing the >> >>>>> different test configurations required by Harmony. Using a >> >>>>> combination of annotations and XML to capture the kinds of >> >>>>> sophisticated test configurations that people need, and that >> >>>>> allows us to specify down to the individual method, has got to be >> >>>>> more scalable and flexible than where we are headed now. >> >>>>> >> >>>>> Thanks for reading this far. >> >>>>> >> >>>>> Best regards, >> >>>>> George >> >>>>> >> >>>>> >> >>>>> [1] >> >>>>> >> http://incubator.apache.org/harmony/subcomponents/classlibrary/testing.html >> >> >>>>> >> >>>>> [2] http://testng.org >> >>>>> [3] >> >>>>> >> http://mail-archives.apache.org/mod_mbox/incubator-harmony-dev/200606.mbox/%3c44A163B3.6080005@googlemail.com%3e >> > > --------------------------------------------------------------------- Terms of use : http://incubator.apache.org/harmony/mailing.html To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org For additional commands, e-mail: harmony-dev-help@incubator.apache.org