Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Junit并行测试日志相互混乱_Junit_Log4j2_Parallel Testing - Fatal编程技术网

Junit并行测试日志相互混乱

Junit并行测试日志相互混乱,junit,log4j2,parallel-testing,Junit,Log4j2,Parallel Testing,我有一些并行运行的测试类和方法。 我使用log4j2进行日志记录,但是到控制台的日志输出互相弄乱了 import org.apache.logging.log4j.LogManager; 导入org.apache.logging.log4j.Logger; 导入org.junit.jupiter.api.Test; 导入org.junit.jupiter.api.parallel.Execution; 导入org.junit.jupiter.api.parallel.ExecutionMode;

我有一些并行运行的测试类和方法。 我使用log4j2进行日志记录,但是到控制台的日志输出互相弄乱了

import org.apache.logging.log4j.LogManager;
导入org.apache.logging.log4j.Logger;
导入org.junit.jupiter.api.Test;
导入org.junit.jupiter.api.parallel.Execution;
导入org.junit.jupiter.api.parallel.ExecutionMode;
@执行(ExecutionMode.CONCURRENT)
公共类TestClass1{
Logger log=LogManager.getLogger();
@试验
公共void test1(){
试一试{
《睡眠》(2000年);
}捕捉(中断异常e){
e、 printStackTrace();
}
log.info(“在“+this.getClass().getName()中执行test1方法”);
}
@试验
公共无效测试2(){
log.info(“在“+this.getClass().getName()中执行test2方法”);
试一试{
《睡眠》(2000年);
}捕捉(中断异常e){
e、 printStackTrace();
}
}
}
希望在test1 TestClass1中看到输出-在TestClass1中执行test1方法

在tests2 TestClass1中—在TestClass1中执行test2方法

当前状态:在第一次或第二次测试中同时打印两个输出,或仅打印一个测试。

看起来IntelliJ IDEA上仍然存在问题

看起来IntelliJ IDEA上仍然存在问题

关于这个问题的问题不会有一天得到解决。 我尝试使用下面bug中提到的TestReporter注入,但是它也不起作用

import org.junit.jupiter.api.Test;
导入org.junit.jupiter.api.TestReporter;
导入org.junit.jupiter.api.parallel.Execution;
导入org.junit.jupiter.api.parallel.ExecutionMode;
@执行(ExecutionMode.CONCURRENT)
公共类TestClass1{
@试验
公共void test1(TestReporter TestReporter){
testReporter.publishEntry(“test1已启动”);
试一试{
《睡眠》(2000年);
}捕捉(中断异常e){
e、 printStackTrace();
}
}
@试验
公共void test2(TestReporter testReporter1){
testReporter1.publishEntry(“test2已启动”);
试一试{
睡眠(5000);
}捕捉(中断异常e){
e、 printStackTrace();
}
}
}
有关此问题的问题不会在某一天得到解决。 我尝试使用下面bug中提到的TestReporter注入,但是它也不起作用

import org.junit.jupiter.api.Test;
导入org.junit.jupiter.api.TestReporter;
导入org.junit.jupiter.api.parallel.Execution;
导入org.junit.jupiter.api.parallel.ExecutionMode;
@执行(ExecutionMode.CONCURRENT)
公共类TestClass1{
@试验
公共void test1(TestReporter TestReporter){
testReporter.publishEntry(“test1已启动”);
试一试{
《睡眠》(2000年);
}捕捉(中断异常e){
e、 printStackTrace();
}
}
@试验
公共void test2(TestReporter testReporter1){
testReporter1.publishEntry(“test2已启动”);
试一试{
睡眠(5000);
}捕捉(中断异常e){
e、 printStackTrace();
}
}

}
是否找到解决此问题的方法?是否使用gradle?如果是的话,你有没有找到解决这个问题的方法?你在用gradle吗?如果是的话。