Practice using Eclipse for unit testing

Source: Internet
Author: User

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

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.