Introduction to the Junit test frameworkThe test framework is the most popular Java unit testing framework. JUnit is used to develop unit tests on Java classes. It is a class package that provides a variety of ways to test methods in a Java class. Junit 4 Features
Simple annotations that provide the basic features of writing
Testing an application with JUnit
You are now ready to test your jn_test application. To test, you also need to use JUnit Wizard to create a new class to extend the JUnit test cases. To use this wizard, right-click on the Jn_test in Package Explorer and select New->other to open a new dialog box, as shown in the figure:
Now expand the Java node and select
JUnit is a unit test framework for the Java language. Founded by Kent Beck and Erich Gamma, it became the most successful of the Xunit family of Sunit from Kent Beck. JUnit has its own JUnit expansion biosphere. Most Java development environments have integrated JUnit as a unit test tool.JUnit is a regression testing f
4. Use JUnit in eclipse
Testing plays an important role in ensuring the quality of software development, and unit testing is essential. JUnit is a very powerful unit testing package, you can test one or more methods of one or more classes, and combine different testcase into testsuit to automate the test tasks. Eclipse
JUnit multithreaded testing
JUnit and its related unit testing techniques
Fourth step, run the test code: After modifying the code as described above, we right-click on the Calculatortest class and select "Run Asàjunit Test" to run our test as shown in:The results of the operation are as follows:Progress bar is red color indicates found error, the specific test results on the progress bar indicate
Using JUnit unit tests can reduce the production of project bugs to some extent. Many times, we are in the main function alone to test a method, such a test is very inconvenient. Using JUnit can be a test unit and project code separation, test multiple methods at once, and evaluate the results.For unit testing in Eclipse, the process is to add the
Continue connection
Open Eclipse new Java project as shown in:
Enter the project name and click the "Finish" button as shown:Create a new Java project in Eclipse, as shown in:
Add the class library as shown in:
Select the JUnit library in the pop-up window, as shown in:Click on the "Next" button and select the
"Turn" junit a dangerous note oneJUnit is a regression testing framework (regression testing framework). JUnit testing is a programmer's test, the so-called white-box test, because the programmer knows how the software being tested (how) accomplishes the function and what it does. JUnit is a set of frameworks that inherit the TestCase class and can be automatical
Eclipse originally provides the running and debugging functions of JUnit. However, in large-scale project development, ant is often used to maintain the compilation, packaging, and testing of the entire code. However, Environment configuration is often performed before testing. These configurations are often completed by ant, so the test entry starts from running ant, however, it is difficult to debug a
Eclipse comes with the JUnit plug-in, which makes it easy to write test cases in a project without having to install them.Add a JUnit library to your projectBefore you can write test cases, you need to introduce JUnit first. Right-click on the project root, select Properties,java Build path,libraries,Add Library, se
To establish a project:
Create a Java project in eclipse.
AntTest -src -com.test -ABS.java -ABSTest.java (Junit Test Case) -lib -build.xml -JUNIT_HOME/junit.jarConfiguration:
Eclipse->window->preference->ant->runtime->classpath->ant Home Entry
Select Add External JAR and join Eclipse_home/plugins/org.junit.../junit.jar
Content of Build.xml:
1 2.? xml ver
1. Use JUnit to test a simple print functionFirst create a test class in projectAdd JUnit LibraryCreate a new JUnit test case in this project and correlate the corresponding class to be tested, select the function to be testedSimple modification of mytest contentRunning (Run as Junit test)2. About MAVENFirst detect if
mobile devices, which makes Android engineers brilliant.3: The advent of the cloud and the popularity of B/s, resulting in the subsequent server-side programming will be very fire, the code will appear refactoring.Second: Common Eclipse Breakpoint debugging1:f5:step into Enter method F6:step over skip F7:step return jumpThe symbol behind the 2:F7 jumps to the first line of the method step to resume:3: Green triangle release Breakpoint or skip to next
(){ Person p = new Person(); p.eat(); }}Special methods for testing classes @before, @Afterimport org.junit.after;import org.junit.before;import Org.junit.test;//person test class public class persontest {private person p; @Before public void before () {System.out.println ("before"); p = new person (); } @Test public void TestRun () {p.run (); } @Test public void Testeat () {p.eat (); } @After public void after () {System.out.println ("after"); }}Here Add t
(){ Person p = new Person(); p.run(); } @Test public void testEat(){ Person p = new Person(); p.eat(); }}The special method of test class @before, @Afterimport org.junit.after;import org.junit.before;import Org.junit.test;//person test class public class persontest {private person p; @Before public void before () {System.out.println ("before"); p = new person (); } @Test public void TestRun () {p.run (); } @Test public void Testeat () {p
Selenium+eclipse+junit+testng+python Step three download Selenium IDE,seleniumrc,iedriverserver, seleniumclient Drivers Selenium official website :http://www.seleniumhq.org/download/1 . Selenium IDE:selenium-ide-2.2.0.xpi is used to record scripts on Firefox. 2, Selenium RC:selenium-server-standalone-2.33.0.jar analog server side, not less. 3, iedriverserver:driverserver_win32_2.33.0.zip IE driver,Firfox
Eclipse comes with the JUnit plug-in, which makes it easy to write test cases in a project without having to install them.Add a JUnit library to your projectBefore you can write test cases, you need to introduce JUnit first. Right-click on the project root, select Properties,java Build path,libraries,Add Library, selec
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.