Software Test Learning log ———— Round 2 junit+intellj idea installation and simple test use

Source: Internet
Author: User

Today is the software test on the computer, the main content is the installation of JUnit and a simple class of test practice. The teacher recommended eclipse, but I used to

Using INTELLJ idea, so I tried INTELLJ idea for JUnit's installation. The procedure is described below.

Installation:

Intellj idea comes with the JUnit module, so it's easy to install.

First, open Intellj idea, double-click the SHIFT key, search for plugins, and click the button in the red line.

  

After entering plugins, search for JUnit, select the checkmark below the red circle plugin, and then confirm and restart Intellj idea.

The installation is complete.

Incidentally, a number of shortcut keys are also one of Intellj idea's charms, making people feel very convenient and developing very comfortably.

Use:

Intellj idea on the use of JUnit is very convenient. You first create a test folder in the SRC Peer directory, which separates the test code from the code being tested. I created here

The Test folder, right-click on the Mark Directory as--->test Source Root

Then create the class to test in SRC, check the class name, press CTRL+SHIFT+T, click Create New test

Enter the test creation interface, such as selecting the arrow to refer to the JUNIT4 to create the test class

Then you can test it!

Test:

The code used for the test:

 Public classJunittest { PublicString Plus (DoubleADoubleBDoublec) {        if(a+b<=c| | b+c<=a| | A+C&LT;=B)return"This was not a trangle"; Else        if(A==B&AMP;&AMP;A==C)return"This was an equilateral"; Else        if(a==b| | a==c| | B==C)return"This was an isosceles"; Else return"This is a Scalene"; }}

Test code:

ImportOrg.junit.Before;Importorg.junit.Test;Import Staticorg.junit.assert.*;/*** Created by LTP on 2016/3/17.*/ Public classJunittesttest {PrivateJunittest Junt; @Before Public voidSetUp ()throwsException {junt=Newjunittest (); } @Test Public voidTestplus ()throwsException {assertequals ("This was not a Trangle", Junt.plus (22,3,4)); Assertequals ("This was an equilateral", Junt.plus (3,3,3)); Assertequals ("This was an isosceles", Junt.plus (3,3,4)); Assertequals ("This is a Scalene", Junt.plus (5,3,4)); }}

Click Edit configurations on the right to configure the operating environment

Then you can run the test!

Test results:

This is the way JUnit is installed and used in Intellj idea.

Software Test Learning log ———— Round 2 junit+intellj idea installation and simple test use

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.