In the evening, I briefly talked with Xiao Bing about the method of using JUnit to test the filenet PE class. The advantage of using JUnit for testing is self-evident when using the main () method in the class. Although the necessity and superiority of lab and JUnit are not significant, it is worth exploring.
As a knowledge point,
Create a Java project and a directory structure
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/4C/75/wKioL1Q902qj5A9lAABreFWsIIw032.jpg "Title =" j.png "alt =" wkiol1q902qj5a9laabrefwsiiw032.jpg "/>
T. Java
Package COM. umgsai. junit4; public class t {public int add (int x, int y) {return X + Y;} public static void main (string [] ARGs) {system. out. println (New T (). add (2, 5); // unit test is to write a class for use by others, test whether there will be a bug // do not use
1. Download the corresponding jar package for junit;
2. Add the path where the jar package is located in Classpath, such as E:\Java\jar\junit\junit-4.10.jar;
3. Add Junit-4.10.jar to the project's Lib folder
4. Window-> Preference-> java-> juinit (or Window-> show View-> java-> J
IDEA Create JUnit
To create junit under idea, you need to install the JUnit plug-in first, in the following steps: "Settings, Plugis, Browse repositories, File--------" Select JUnit G Enerator V2.0 installation, restart Idea "
To create a JUnit test class for a class, you
I. Definition of ClassFirst, create a project named JUNIT4, and define the calculator class to perform subtraction operations under the project.Ii. Introduction of JUnit Projects1. Introduce the JUnit unit test package into this project, right click on the properties on the project, then Java Build Path, then click on Libraries, right click on the add Library, for example:2. Select
I. the process of installing Junit,hamcrest and eclemma1. Download Junit 's jar Package and hamcrest, which is currently available in version JUnit 4.12, which can be downloaded from www.junit.org . 2.OpenEclipse, when you want to useJunitof theProjectname, clickProperties--java Build Path-libraries, clickAdd External JARs, putJuniton the package point. 1as shown
I have been testing these days. The operating system is Solaris and JUnit is used, probably because my level is too low ). The first time I wrote a test case, many things were also vague. The function to be tested yesterday was to use log4j to output logs. As always, I wrote test cases, run JUnit, and input the name of the test case class, click the run button and the following error is found:
Log4j: Er
JUnit Unit tests:1. What is unit testing: After we have completed a project, we need to make a simple full-aspect test of its code logic, to see if the code logic is correct, for example, we wrote a log of the code, test, we will use the mobile phone number, account to log in to see if it can be boarded, if the wrong password or account to see if All these need to be tested, and the test will be handed in after the success. Testing is done in case the
Java beginner, want to try to connect to the local database, according to Baidu experience in the method, the last to perform the test stuck, why? Because the MyEclipse right-click Run as does not have the junit test option!6.1, test database mysql is a successful connection in the project, running the test class when run as does not have Junit test; 6.2, because the project did not introduce
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 JUnit class lib
The content of this section:
The meaning of spring's integration with JUnit testing
Spring consolidates JUnit tests
The meaning of spring and integrated JUnit testingPrior to the integration of JUnit, we wrote the test method by manually creating the container in each method, getting the object, such
1. We know that JUnit tests are available in both J2SE and Android, and using JUnit can help facilitate the testing of code. In my previous blog, I also wrote some examples of junit tests in J2SE, today for a little discussion of junit in spring.The jar package required for this spring test:Spring-test-3.2.0.release.ja
, the concept of refactoring is introduced to make the code cleaner and more resilient.
Ø to enhance the reliability of the system, it is a regression test. Support repair or correction of "re-test" to ensure the correctness of the code.
2.2, unit test for the object
Ø process-oriented software development for processes.
Ø object-oriented software development for objects.
Ø can do class testing, functional testing, interface testing (most commonly used in the test class methods).
2.3. Unit
Those of you who have written JUnit unit tests should have a feeling thatJUnit itself does not support normal multithreaded testing , because the underlying implementation of JUnit is executed with the System.exit exit use case. The JVM is terminated, and other threads that are started by the test thread will not be able to execute naturally. The Junitcore code is as follows:/*** Run The tests contained in
Experiment Name:The first experiment of software testingExperimental Purpose:Learn about the use of junit,hamcrest,eclemma these Intelij idea plugins or development packagesExperimental content:Write a Java program to determine whether a given triangular triangle is equilateral triangle, isosceles triangle, or non-equilateral triangle, and uses Junit,hamcrest,eclemma for functional testing and coverage test
Compounding Calculator 4.0 in the second encounter with JUnit
Objective
Although the previous compound interest Calculator version has tried to use JUnit unit testing, it is not well-used because it has not been systematically studied, and the main problem is that there are too few scenarios to test, and not to achieve the comprehensiveness required for testing, Failed to embody the essence o
First, the addition function to test1. Instantiate the unit (method): Class name Instance name =new class name ([parameter])2. Call the unit under test, compare the expected value and output value (actual value);In the absence of the JUnit test tool, we will do the following test code writing process:Ii. using JUnit for unit testingJUnit is a unit test tool for Java-language-specific code, and is a Java-bas
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.