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<=B)return"This was not a trangle"; Else if(A==B&&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