Practice using Eclipse for unit Testing 1.Eclipse installation (1) go to the website to download eclipse
Click Eclipse IDE Downloads
Click Download to complete the download.
(2) Download JDK
Go online to find the JDK below (64-bit)
(3) Setting environment variables
Click this computer Right button property, advanced system settings.
Click Environment Variables.
Edit the variable names and variable values of classpath and JAVA_HOME0 in the system variables.
Environment variables are set.
(4) Running eclipse
2. Unit Test (1) New project test
Click Finish.
(2) New class
Give the package name, name (class name), where name begins with a letter.
Click Finish.
(3) New test
Click Finish.
(4) test
Add the following code to the Ma.java:
Select Ma.class, right-click, New-->junit Test case.
Click Finish.
Add the following code to the Matest.java:
Now test, select Matest.java, right-click, Run as-->junit Test.
Click OK.
The results are as follows:
Run correctly.
(1) Runs: There are a total of several test methods, have been running a few;
(2) Errors: Indicates the number of test methods that throw an exception;
(3) Failures: Indicates the number of failed test methods;
(4) Hook: Indicates passing test method.
(5) Another green progress bar indicates a successful test, and a red progress bar indicates that the test failed.
(5) Automatic test
Select Ma.java, right-click, new,other
Click Next to rename the name to Maautotest
Tick the function you want to test
You can then see the corresponding test methods that are automatically generated.
and change the test data as
As tested above, the results are as follows
Run correctly.
Practice using Eclipse for unit testing