开发者

Group testNG tests without annotations

I'm responsible for allowing unit tests for one of ETL components.I want to acomplish this using testNG with generic java test class and number of test definitions in testng.xmlpassing various parameters to the class.Oracle and ETL guys should be able to add new tests without changing the java code, so we need to 开发者_运维技巧use xml suite file instead of annotations.

Question

Is there a way to group tests in testng.xml?(similarly to how it is done with annotations) I mean something like

<group name="first_group">
   <test>
   <class ...>
   <parameter ...>
   </test>
</group>

<group name="second_group">
 <test>
   <class ...>
   <parameter ...>
   </test>
</group>

I've checked the testng.dtd as figured out that similar syntax is not allowed.But is therea workaround to allow grouping?

Thanks in advance


You can specify groups within testng.xml and then run testng using -groups

<test name="Regression1">
  <groups>
    <run>
      <exclude name="brokenTests"  />
      <include name="checkinTests"  />
    </run>
  </groups>
  ....


No, this is not possible at the moment.

As a rule of thumb, I don't like adding information in XML that points into Java code, because refactorings might silently break your entire build.

For example, if you rename a method or a class name, your tests might start mysteriously breaking until you remember you need to update your XML as well.

Feel free to bring this up on the testng-users mailing-list and we can see if there's interest for such a feature.

--

Cedric

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜