Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.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
Unit testing 使用Jacoco和Sonar进行单独单元和集成测试_Unit Testing_Integration Testing_Sonarqube_Jacoco - Fatal编程技术网

Unit testing 使用Jacoco和Sonar进行单独单元和集成测试

Unit testing 使用Jacoco和Sonar进行单独单元和集成测试,unit-testing,integration-testing,sonarqube,jacoco,Unit Testing,Integration Testing,Sonarqube,Jacoco,我从声纳github取了组合ut-it多模块maven jacoco。基本上,这个示例有一个带有单元测试的模块和另一个带有集成测试的模块。UT的覆盖率为40%,IT的覆盖率为50%,总体覆盖率为80% 然后,我在app模块中为未覆盖的代码添加了一个新的单元测试: package example; import org.junit.Test; public class HelloWorldAnotherUnitTest { @Test public void test() {

我从
声纳github
取了
组合ut-it多模块maven jacoco
。基本上,这个示例有一个带有单元测试的模块和另一个带有集成测试的模块。UT的覆盖率为40%,IT的覆盖率为50%,总体覆盖率为80%

然后,我在
app
模块中为未覆盖的代码添加了一个新的单元测试:

package example;

import org.junit.Test;

public class HelloWorldAnotherUnitTest {

    @Test
    public void test() {
        new HelloWorld().notCovered();
    }

}
UT的覆盖率为60%,IT的覆盖率为50%,总体覆盖率为100%。到目前为止还不错

我将该测试从
app
切换到
app it
模块,UT的覆盖率为40%,it的覆盖率为70%,总体覆盖率为100%。在这里,我期待着与先前报道相同的结果


因此,似乎特定模块的覆盖范围可以是单元或集成。这是一个错误吗?

对不起,我真的不明白问题出在哪里。。。如果您将测试用例从UT移动到ITs,那么UT覆盖率降低而IT覆盖率增加看起来很正常…测试仍然是UT,但我只是将它放在
app IT
中,而不是
app
。因此它不被视为UT而是IT,有什么问题吗?
HelloWorldAnotherUnitTest
是UT,因此,它的覆盖率应该计入UT覆盖率,而不是现在的IT覆盖率。这说明JUnit/TestNG测试类是UT或IT,它是放置它的位置,而不是在类中执行的操作。当你把它放在“应用程序it”中时,你清楚地表明这是一个it,而不是UT。