Junit 4 allows you to run test classes in bulk by using test suite classes. To create a test suite for a set of test classes, add the following annotations for the
Junit4.x test runnerJUnit provides the default test runner for unit tests. It is responsible for executing all testing methods.We can also customize our own runners, all of which are inherited fromOrg. JUnit. Runner. Runner You can also useOrg. JUnit. runer. runwith AnnotationSpecify a specific runner for each
Perform unit tests on the following three classes to form a suite test.
add( a, a + sub( a, a -
4
getArea( width, width*
Test code: We recommend that you put the test code in the test source file.
setUp() = result = calculate.add(12, 1224 result = calculate
for special needs.Test suiteIn the actual project, with the progress of the project, the Unit test class will be more and more, but until now we will only one single run test class, which in actual project practice is certainly not feasible. To solve this problem, JUnit provides a way to run the test class in batches,
Junit Test @ test red name problem, junit Test @ test
Prepare for testing. For example, all are named Red.
Ctrl + 1 or move the cursor over @ Test
Place the cursor on @
the test class (such as the Unit test code mentioned above). In general, the default test runner can handle the overwhelming majority of unit testing requirements, and explicitly declaring a Test runner is essential when you use some of the advanced features provided by JUnit
with clear test results
1.2.2 provides three methods to display your test results, and can be expanded.
1.2.3 provides the unit test case batch operation function
1.2.4 ultra-lightweight and easy to use, without commercial spoofing and useless wizard
1.2.5 the entire framework is well designed and easy to expand
1.3 JUnit
(i) Test Suite test SuiteA test suite is a collection of multiple tests or test cases, a set of tests that are created for the corresponding functions and modules of the program under test
JUnit Unit Test Tutorial-The ultimate guide
The ultimate guide to JUnit Unit Testing tutorials
Description
Introduction to Unit Testing
1 What is unit testing
2 Test coverage
3 unit tests in Java
About JUnit
The multi-thread test sub-thread of Junit unit is not executed, and the multi-thread test of junit isThe child thread of the Junit unit test is not executed.
The child thread of the Junit
Unit test framework junit, unit test junit
# Unit test junit* Define a class that inherits AndroidTestCase. Define a method in the class to test this method.
* When specifying the comma
JUnit unit test (2) -- JUnit Basics
1. Basic Introduction
1. JUnit is a framework for testing code. The purpose of testing is to ensure that the Code is correct, rather than the code is correct.
2. The test class should not be put together with the target class, but the comp
Regular Expression and junit test, regular expression junit
You need to know some regular expression statements, and then write the regular expression statements following the rules. Then, it is about junit testing.
After learning about a document you have read, you can take a look at the document, or search for it l
Recently, at the request of the boss, study the spring test related things, and strive to make a convenient use of testing tools, for a spring is not familiar to the JUnit people this is a big pit, swept aside spring test document did not feel any gain, What spring does is just context-sensitive, and the main entrance I want is
completed.
The JUnit test framework class structure is simple, consisting mainly of 3 classes, whose class diagram relationships are shown in the following illustration:
Wrong figure! Text with no specified style in the document. JUnit Test Framework class structure
junit.framework.test:
Why do you write unit tests?Enterprise development, regardless of the size of the project are inseparable from testing, including unit testing, regression testing, performance testing and so on, and unit testing is to verify that the programmer is the correct way to write code, in the day-to-day development of unit testing is very necessary, imagine if you are developing a huge project, If each of the business logic written by the deployment to the server to run the program through the front int
test code runFirst, the most common integration patterns.After the test code is written, you can write the main method in the corresponding class, run it directly with the Java command, or do not write the main method and run it with the JUnit-supplied runner. JUnit provides three types of Textui,awtui and Swingui act
functional features of JUnit 4 and TestNG.
Annotation Support
The implementations of Junit 4 and TestNG are very similar in terms of annotations.
Characteristics
JUnit 4
Testng
Test annotations
@Test
@
I. A. py file executes the test case in bulk (a. py file under multiple use cases)If used directly: Unittest.main (), it is executed in alphabetical order,The use of Suite.addtest (the class name ("Method name"), which is the order of additions, modifications, and deletions, avoids the processing of the test data after the completion of the use cases, which are dependent on each other, and need to be execut
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.