Example of a DAO layer built with the JUnit Test Spring framework:
Package Com.project.dao;
Import Java.text.DateFormat;
Import Java.text.SimpleDateFormat;
Import java.util.Date;
Import Org.junit.Assert;
Import Org.junit.Test;
Import Org.junit.runner.RunWith;
Import org.springframework.beans.factory.annotation.Autowired;
Import org.springframework.test.context.ContextConfiguration;
Import Org.springf
After the project adds MAVEN support, run the JUnit unit test and an error occurs:
ERROR in Ch.qos.logback.core.joran.action.appenderaction-could not create a appender of type [COM.TRAVELSKY.TDP.P KgStock.integration.logback.appender.mail.SMTPAppender]. Ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type Com.travelsky.tdp.pkgStock.integration.logback.appender.mail.SMTPAppen
The distance from the last time to do junit monomer test for several months, and sure enough to use, and learn some new things, summed up.
The first is the understanding of the spy, has been used to mock, did not use the spy, so the spy does not understand, recently used a few times, also in Google learning a bit, online said are more written, mock: all Mock;spy: part of the mock; What is called part bu
Uploading an array using JSON1 Packagejunittest;2 3 Importjava.util.ArrayList;4 ImportJava.util.HashMap;5 Importjava.util.List;6 ImportJava.util.Map;7 Importorg.junit.Test;8 ImportCom.alibaba.fastjson.JSON;9 ImportVO.RESVO;Ten ImportInterfacetest_1.httputil; One A Public classUserInfo { - - //set up a common menu the @Test - Public voidSetMenu () { - intMenuId = 1; - intOrder = 1; +
Directly on the code package dependency please add your own Maven added dependency is very convenient1, Testbase.javaPackage Com.test;import Org.apache.commons.logging.log;import Org.apache.commons.logging.logfactory;import Org.junit.before;import Org.junit.runner.runwith;import Org.springframework.test.context.activeprofiles;import Org.springframework.test.context.contextconfiguration;import Org.springframework.test.context.junit4.SpringJUnit4ClassRunner, @RunWith (Springjunit4classrunner.class
Today, I encountered a strange thing. I configured transactions in the Spring configuration file and performed transactions on all methods at the Service layer. However, when I tested one of the methods, it is found that it is not a transaction, and the first operation in it is completed, but the second operation fails. The reason is found. It turns out that the try and catch statement blocks are used inside this method, so that exceptions are caught internally. In Spring, transaction rollback i
The most recent use of the DAO injected by the JUnit Test Spring produces a strange javaw.exe error that needs to be closed.
At first I thought it was the configuration file or the code was wrong, but the check did not identify the problem. So sent to a friend that implementation, his computer on the implementation immediately green, depressed 2 days also can not solve, should be aware of the problem of th
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.