小编Avi*_*rni的帖子

JUnit测试用程序通过eclipse传递但是使用maven构建失败

我使用spring为JPA编写了一个JUnit测试用例.测试用例通过eclips.但是如果我使用maven(mvn test)执行相同的测试用例,它就会失败.

我的测试用例是:

import javax.annotation.Resource;

import junit.framework.TestCase;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:config/servicecontext-standalone.xml")
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback =      false)
@Transactional
public class UserServiceImplTest extends TestCase {

@Resource(name = "UserService")
private UserService userService;

public UserServiceImplTest() {
}

public UserService getUserService() {
    return userService;
}

public void setUserService(UserService userService) {
    this.userService = userService;
}

@Test
public void testFindUser() {
    try {
        UserFindRequest pUserFindRequest = new UserFindRequest();
        pUserFindRequest.setUserId(1);
        UserServiceImpl aUserServiceImpl = (UserServiceImpl) this …
Run Code Online (Sandbox Code Playgroud)

eclipse spring jpa testcase maven

3
推荐指数
1
解决办法
4562
查看次数

标签 统计

eclipse ×1

jpa ×1

maven ×1

spring ×1

testcase ×1