存放位置
- 要和项目启动类同一个包名路径下对应起来
pom.xml
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
测试类
- 若报错
javax.websocket.server.ServerContainer not available
则注解改为贴@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@RunWith(SpringRunner.class)
@SpringBootTest
public class test {
@Autowired
private CfgInterfaceWeightMapper cfgInterfaceWeightMapper;
@Test
public void test1(){
List<CfgInterfaceWeight> weightInterFaceList = cfgInterfaceWeightMapper.findWeightInterFaceList();
System.out.println(weightInterFaceList.get(0).getInterfaceName());
System.out.println(weightInterFaceList.size());
}
}