TestNG Example"
From Documentation
m (correct highlight (via JWB)) |
|||
(5 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
+ | This test case performs exactly the same as the JUnit one except that it is written in TestNG's annotation, please refer to [http://testng.org/doc/index.html]. | ||
To run a TestNG test case, please refer to [http://testng.org/doc/documentation-main.html#running-testng Run TestNG]. | To run a TestNG test case, please refer to [http://testng.org/doc/documentation-main.html#running-testng Run TestNG]. | ||
− | <source lang="java" | + | <source lang="java" highlight="12"> |
public class HelloTestNg { | public class HelloTestNg { | ||
Line 39: | Line 40: | ||
</source> | </source> | ||
− | * It has little difference | + | * It has little difference to the JUnit test case. You only need to change <code> @After </code> to <code> @AfterMethod </code> and <code> import org.junit.* </code> to <code> import org.testng.* </code>. |
− | |||
+ | {{ZATSEssentialsPageHeader}} | ||
{{ZATSEssentialsPageFooter}} | {{ZATSEssentialsPageFooter}} |
Latest revision as of 13:46, 19 January 2022
This test case performs exactly the same as the JUnit one except that it is written in TestNG's annotation, please refer to [1].
To run a TestNG test case, please refer to Run TestNG.
public class HelloTestNg {
@BeforeClass
public static void init() {
Zats.init("./src/main/webapp");
}
@AfterClass
public static void end() {
Zats.end();
}
@AfterMethod
public void after() {
Zats.cleanup();
}
@Test
public void test() {
DesktopAgent desktop = Zats.newClient().connect("/hello.zul");
ComponentAgent button = desktop.query("button");
ComponentAgent label = desktop.query("label");
//button.as(ClickAgent.class).click();
button.click();
Assert.assertEquals("Hello Mimic", label.as(Label.class).getValue());
}
}
- It has little difference to the JUnit test case. You only need to change
@After
to@AfterMethod
andimport org.junit.*
toimport org.testng.*
.