| <html> |
| <head> |
| <title>TestNG - Migrating from JUnit</title> |
| |
| <link rel="stylesheet" href="testng.css" type="text/css" /> |
| <link type="text/css" rel="stylesheet" href="http://beust.com/beust.css" /> |
| <script type="text/javascript" src="http://beust.com/prettify.js"></script> |
| <script type="text/javascript" src="banner.js"></script> |
| |
| <script type="text/javascript" src="http://beust.com/scripts/shCore.js"></script> |
| <script type="text/javascript" src="http://beust.com/scripts/shBrushJava.js"></script> |
| <script type="text/javascript" src="http://beust.com/scripts/shBrushXml.js"></script> |
| <script type="text/javascript" src="http://beust.com/scripts/shBrushBash.js"></script> |
| <script type="text/javascript" src="http://beust.com/scripts/shBrushPlain.js"></script> |
| <link type="text/css" rel="stylesheet" href="http://beust.com/styles/shCore.css"/> |
| <link type="text/css" rel="stylesheet" href="http://beust.com/styles/shThemeCedric.css"/> |
| <script type="text/javascript"> |
| SyntaxHighlighter.config.clipboardSwf = 'scripts/clipboard.swf'; |
| SyntaxHighlighter.defaults['gutter'] = false; |
| SyntaxHighlighter.all(); |
| </script> |
| |
| </head> |
| <body onLoad="prettyPrint()"> |
| |
| <script type="text/javascript"> |
| displayMenu("migrating.html") |
| </script> |
| |
| |
| <h2 align="center">Migrating from JUnit</h2> |
| |
| <h3>Using Eclipse</h3> |
| |
| The easiest way to convert your JUnit tests to TestNG is to use the Eclipse TestNG plug-in refactoring support. You will find a full description of its features in the <a href="eclipse.html#eclipse-quickfix">Eclipse section</a>. |
| |
| <h3>Asserts</h3> |
| Note that the class <tt>org.testng.Assert</tt> uses a different argument ordering than the ones used by JUnit. If you are porting code that uses JUnit's asserts, you might want to us a static import of that class: |
| |
| <pre class="brush: java"> |
| import static org.testng.AssertJUnit.*; |
| </pre> |
| |
| <h3>Related reading</h3> |
| |
| <a href="http://www.opengamma.com/blog/2011/converting-opengamma-junit-testng">Here is the detailed report of a company that successfully converted a large codebase of JUnit 4 tests over to TestNG</a>. |
| |
| <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> |
| </script> |
| <script type="text/javascript"> |
| _uacct = "UA-238215-2"; |
| urchinTracker(); |
| </script> |
| |
| |
| </body> |
| |