text: Richard Liang wrote:
  >
  >
  > George Harley wrote:
  >> Richard Liang wrote:
  >>>
  >>>
  >>> George Harley wrote:
  >>>> Hi,
  >>>>
  >>>> ?
  >>>>
  >>> 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.
  >
  > <groups>
  > <run>
  > <include name=".*" />
  > <include name="os.win.IA32" />
  > <exclude name="type.impl" />
  > <exclude name="state.broken" />
  > <exclude name="state.broken.win.IA32" />
  > <exclude name="os.linux.IA32" />
  > </run>
  > </groups>
  >
  > 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 ...
  <testng jvm="${test.jre.home}/bin/java">
  <classpath location="${test.build.dir}"/>
  <jvmarg value="-showversion" />
  <jvmarg value="-Dhy.platform=win.IA32"/>
  <xmlfileset dir="${basedir}"
  includes="testng-with-beanshell.xml"/>
  <classfileset dir="${test.build.dir}"
  includes="**/*Test.class" />
  </testng>
  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)...
  <test name="current.platform.api">
  <method-selectors>
  <method-selector>
  <script language="beanshell"><![CDATA[
  import apples.*;
  platform = System.getProperty("hy.platform", "null");
  if (platform.equals("null")) {
  System.out.println("Property hy.platform not set");
  return false;
  }
  if ( !groups.containsKey("type.impl") &&
  TestUtils.matchesAnyGroup(testngMethod.getGroups(),
  "os." + TestUtils.getPlatform()) &&
  !groups.containsKey("state.broken") &&
  !groups.containsKey("state.broken." + platform) ) {
  return true;
  }
  return false;
  ]]></script>
  </method-selector>
  </method-selectors>
  <packages>
  <package name="foo.bar"/>
  </packages>
  </test>
  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(). ?
  Best regards,
  George
  >> Best regards,
  >> George
  >>
  >>
  >>
  >>>> posts
  >>>>>