Migration from jUnit to TestNG



If we choose to make TestNG as the testing library in our automation framework , we can easily do that with the Eclipse/IntelliJ Plugins:


Excellent report on converting an entire project from jUnit to TestNG https://developers.opengamma.com/blog/2011/04/04/converting-opengamma-junit-testng


Use caseJUnit 4TestNGComment
Method is a test@Test@TestSimply change the import
Class is a testN/A@TestWe decided to stick with
per method annotations
in the end
Test is disabled@Ignore@Test(enabled=false)@Ignore on the class
disables all tests
 in the class, whereas @Test
(enabled = false) on the class
doesn't override @Test
on a method
An exception is expected@Test
(expected
=IOException.class)
@Test
(expectedExceptions
=IOException.class)
Simple spelling change
Test timeout@Test(timeout
=20000)
@Test(timeOut=20000)Simple spelling change
Run before/after each test method@Before/@After@BeforeMethod/
@AfterMethod
Clearer annotation name
Run before/after each test method@BeforeClass
/@AfterClass
@BeforeClass
/@AfterClass
JUnit requires a static method,
TestNG allows either a static
or an instance method
Run before/after
each entire test suite
N/A@BeforeSuite/
@AfterSuite

Comments

Popular posts from this blog

XPATH for IE / internet explorer

All time good software testing books!