2

I'm using TestNG for some time now but still I don't know what's the intended purpose of those two (@Test and < test> in suite.xml)and what abstractions they are meant to express.

Also if anyone can share the difference in their behavior regarding other elements in TestNG. For example are @AfterTest @BeforeTest triggered by @Test or <test> and which one of @Test and < test> gets into the final execution report.

4

2 に答える 2

3

@Test試験方法を示します。<test>で複数のクラスをグループ化する方法ですtestng.xml

于 2013-03-05T17:09:06.263 に答える
3

セドリックの答えに加えて、2番目の質問について

@AfterTestはxmlで実行されます

@AfterMethodは、Javaファイルの@Testの後に実行されます。

例えば。

public class TestCases{
@Test
public void test1()..
@Test
public void test2()..
}

public class MoreTestCases{
@Test
public void test1()..
@Test
public void test2()..
}

つまり、@Testで注釈が付けられた4つのテストケースがあります

さて、xmlには、テストの実行をどのように構成するかが含まれています

 <test>
   <classes>
    <class name = TestCases>
      <methods>
        <include name = test1/>
      </methods>
    </class>
   <class name = TestCases>
     <methods>
       <include name = test1/>
     </methods>
   </class>
  </classes>
</test>

したがって、現在は両方のクラスからtest1のみが実行されます。

用語は最初は少し混乱します...しかし、それが物事を少し明確にするのに役立つことを願っています。

于 2013-03-05T20:00:50.250 に答える