Program JUnit test Program writing specification
First, program naming code
1. The name
of the test class
The naming rule for the test class is: The class name of the class being tested +test
such as a class called Irgsrhdelegate, then its
Original article: test execution orderOriginal Article Date: January 1, December 06, 2012Translated on: February 1, July 2, 2014Translated by: TieNote: junit4.11 and later are supported. We recommend that you upgrade it to the latest version.According to the design principles, JUnit does not specify the execution sequence of test method calls.So far, these method
Remember the previous contact with JUnit, the test of the public method is very fluent, and the private method is also called in these public methods, will test coverage.
Because is the new class, the new method, makes the data step by step the cover to run down, really as long as has the patience, can be done.
But as the project gradually deepened, due to pers
Quickly build an Android jUnit test environment
Classification of tests:Source code transparency: black box testing: Unknown source code, relational user operations. White-box testing: Write test cases based on source code. Test granularity: method test: function
, will produce dirty data, affecting the correctness of our data
Inconvenient cyclic testing, that is, if we delete a record this time, next time we can no longer carry out the JUnit test, because the record has been deleted, will be error.
If we do not use transaction rollback, we need to explicitly restore our additions and deletions to the database operation in the code, will be much more and
Usually we do not have to do the SSH project to do unit testing, and many times, we do not want the results of unit testing on the real database has an impact, then we need to use the transaction to manage.The JUnit test base classes are as follows:Package Com.sms.test.base;import Org.junit.runner.runwith;import Org.springframework.test.context.contextconfiguration;import Org.springframework.test.context.te
using ant to integrate JUnit for Automatic Testing and generate test reports can greatly improve the test efficiency. The advantage is the batch processing function of test cases. Not long ago, I saw a lot of articles about JUnit testing on the Internet: . I'm glad ant has
steps:1. New package (generally named *. Test, the testing class and the development class are placed in different packages)2. New JUnit Text case (generally named *test)3. Select the method you want to test4. You can download the latest jar package, or you can select the system's own: www.junit.orgStatic Introduction:import static org.junit.assert.*;a static cla
Android junit unit test, androidjunit
Classification of software testing* Black box testing* Test the logical business* White box testing* Test logic method
Based on test Granularity* Method test: function
The course design requires the JUnit test, which I tested on the already well-done SSH project, and the test class code is as followsPackage Com.zhang.web.services;importStaticorg.junit.assert.*; import org.junit.after;import org.junit.before;import org.junit.test;import javax.annotation.Resource; Import Org.junit.runner.RunWith; Import Org.springframework.test.
After the configuration is successful, you need to start the test case!
Package com. CMC. controller;Import javax. annotation. Resource;Import org. junit. Test;Import org. junit. runner. RunWith;Import org. springframework. test. context. ContextConfiguration;Import org. sp
By doing web development, you find that testing becomes more complicated after object management through spring.
Because all the beans need to be loaded in the Applicationcontext.xml, and then through the @resource to get.
If you want the entire business stream to do almost every time to test, this is very inefficient and cumbersome. It's too tedious to write a test class on your own.
Then I thought spring
Using the spring framework to make it easy to write code with separate tests for some code snippet code without having to run the entire environment for testing, the JUnit test is introduced to facilitate the testing of the local code block.1, first guide package, such as MAVEN project: where JUnit needs at least in the 4.12 version, or will be error 2 Create a
Original link: Test execution orderOriginal date: December 06, 2012 ThisDate: July 2, 2014Translators: AnchorDescription: Junit4.11 version number and later support, it is recommended to upgrade to the latest version number.In accordance with the design principle, JUnit does not specify the order in which the test method calls run.For now, these methods simply ru
Examples are as follows: Packagecom.junge.demo.spring;Import Staticorg.junit.Assert.assertEquals;Importjava.util.List;Importorg.junit.Test;ImportOrg.junit.runner.RunWith;Importorg.springframework.beans.factory.annotation.Autowired;Importorg.springframework.test.context.ContextConfiguration;ImportOrg.springframework.test.context.junit4.SpringJUnit4ClassRunner;ImportCom.junge.demo.spring.service.IPerface;ImportCom.junge.demo.spring.service.ServiceConfig;/*** Unit
JUnit Common annotations:
@Before: Initialization method
@After: Freeing Resources
@Test: Test method, where you can test for expected exceptions and time-outs
@Ignore: Ignored test methods
@BeforeClass: For all tests, execute only once and must be static vo
The MyEclipse item has a red exclamation point and each package is displayed as normal. With JUnit test part can run, partial error, error is as follows:Class not found N_JDBC. UserdaotestJava.lang.ClassNotFoundException:n_jdbc. UserdaotestAt Java.net.urlclassloader$1.run (urlclassloader.java:200)At java.security.AccessController.doPrivileged (Native Method)At Java.net.URLClassLoader.findClass (urlclassload
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.