测试类的包名和启动类包名一致
package com.xxx.tiny;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class Tests {
@Autowired
private AdminService adminService ;
@Test
public void test1() {
adminService .gexxx(5L);
}
}
测试类的包名和启动类包名不一致
package com.test;
import com.xxApplication;
import org.junit.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = xxApplication.class)
public class test{
@Autowired
private AdminService adminService ;
@Test
public void test1() {
adminService .gexxx(5L);
}
}