No tests were found
No tests were found
问题分析
1、
进行单元测试Q的方法不能有返回值,否则会报No test were found
2、进行单元测试的方法不能私有化
3. junitQ版本问题
问题分析
1、
进行单元测试Q的方法不能有返回值,否则会报No test were found
2、进行单元测试的方法不能私有化
3. junitQ版本问题
问题分析
1、
进行单元测试Q的方法不能有返回值,否则会报No test were found
2、进行单元测试的方法不能私有化
3. junitQ版本问题
下面这个会报错!!!
package com.kgc.mynacos.myconfig;
import com.kgc.mynacos.myconfig.services.ReadConfService;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;import javax.annotation.Resource;
@SpringBootTest
public class MyTest {
@Resource
private ReadConfService rcs;@Test
private void test01(){
while(true){
System.out.println(rcs.getInfo());try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}}
}
改成下面这个就行!
package com.kgc.mynacos.myconfig;
import com.kgc.mynacos.myconfig.services.ReadConfService;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import javax.annotation.Resource;
@SpringBootTest
public class MyTest {
@Resource
private ReadConfService rcs;
@Test
public void test01(){
while(true){
System.out.println(rcs.getInfo());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
}
#注意:Test导包有2个 选api这个
#@springBootTest后面单词别拼错
#测试类使用 不要使用private!!!!!不然报错no tests were found