Since getting started with j2se 5.0, it seems that the name of Cedric beust is lingering in my mind. It's about an introduction to the new features of j2se 5.0 in java.sun.com. Article In fact, the French are most impressed by the test tool he created based on JUnit and j2se 5.0 annotation (annotation): testng.
Friends who have used JUnit, especially those who often use it, will probably feel the same way, that is, JUnit sometimes seems too monotonous and inflexible, but few people just set up their own test frameworks as they do. Maybe this is the gap between us and developed countries in technological innovation. I think this is at least the gap in consciousness.
Chinese and foreign websites have already made many introductions before and after, and Chinese websites seem to have not paid much attention to this seemingly inconspicuous guy. What kind of tool is this? What are the characteristics? The general summary is:
Support for Java annotations
Xml configuration test process
You do not need to implement interfaces or inherit classes (such as the testcase/testsuite of JUnit)
Supports independent methods and Groups
Support for parallel testing
The test method supports passing parameters.
Arbitrary call count and success rate statistics
Now we have the opportunity to try this test framework in the eclipse environment. We also want to thank the testng plug-in author Alexander Ru Popescu for sacrificing so much time. How is it? Eager to try? The Update site of this plug-in is: http://beust.com/eclipse/. currently, only the eclipse 3.1 version is supported, because of Java annotations.
For a simple demonstration, I wrote someCode:
[Foocalculator. Java]Package Sean. Home. test;
Public Class Foocalculator {
Public Static Int Increasebyone ( Int Origval) {
Return ++Origval;
}
}
[Foocalculatortest. Java]Package Sean. Home. test;
Import com. beust. testng. annotations. * ;
Public Class Foocalculatortest {
Private Int Origval;
@ Configuration (beforetestclass = True )
Public Void Setup () {
Origval=Integer. max_value;
}
@ Test
Public Void Testincreasbyone () {
IntResult=Foocalculator. increasebyone (origval );
Assert result> 0;
}
}
[Testfoocalculator. xml] <! Doctype suite System "http://beust.com/testng/testng-1.0.dtd" >
< Suite Name = "Custom suite" >
< Test Name = "To test foocalculator" >
< Classes >
< Class Name = "Sean. Home. Test. foocalculatortest" />
</ Classes >
</ Test >
</ Suite >
After that, right-click eclipse and select our test class or configuration file to run testng. Then we can see the results displayed in the console view and testng view.
For more information, see http://beust.com/testng /. I hope it will be helpful to nunit enthusiasts and learners.