REM:
1. 设备测试添加回滚操作
2. 指定测试用配置文件为test
This commit is contained in:
huangxin 2020-04-27 14:10:34 +08:00
parent 08ea6568c4
commit 542478e5e3
1 changed files with 19 additions and 5 deletions

View File

@ -1,5 +1,6 @@
package com.dispose.manager; package com.dispose.manager;
import com.dispose.Global.InitTestEnvironment;
import java.util.List; import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -8,6 +9,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.util.ReflectionTestUtils; import org.springframework.test.util.ReflectionTestUtils;
@ -16,29 +18,41 @@ import com.dispose.pojo.entity.DisposeDevice;
import junit.framework.TestCase; import junit.framework.TestCase;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
/** /**
* * The type Dispose device manager test.
*
* @author phoenix
* @date 2020年4月27日
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest @SpringBootTest
@Slf4j @Slf4j
public class DisposeDeviceManagerTest { @Transactional
@Rollback
public class DisposeDeviceManagerTest extends InitTestEnvironment {
/**
* The Dispose device mapper.
*/
@Resource @Resource
private DisposeDeviceMapper disposeDeviceMapper; private DisposeDeviceMapper disposeDeviceMapper;
/**
* The Dispose device manager.
*/
@Resource @Resource
private DisposeDeviceManager disposeDeviceManager; private DisposeDeviceManager disposeDeviceManager;
/**
* Sets up.
*/
@Before @Before
public void setUp() { public void setUp() {
ReflectionTestUtils.setField(disposeDeviceManager, "disposeDeviceMapper", disposeDeviceMapper); ReflectionTestUtils.setField(disposeDeviceManager, "disposeDeviceMapper", disposeDeviceMapper);
} }
/**
* Test dispose device manager.
*/
@Test @Test
public void testDisposeDeviceManager() { public void testDisposeDeviceManager() {
log.info("DisposeDeviceManager 单元测试"); log.info("DisposeDeviceManager 单元测试");