自动化生成测试用例pom配置G了 您所在的位置:网站首页 idea自动生成测试用例 自动化生成测试用例pom配置G了

自动化生成测试用例pom配置G了

2023-04-13 08:15| 来源: 网络整理| 查看: 265

我在使用evosuite时与jacoco产生了冲突导致jacoco代码覆盖率为0,找到了原因所在处,是自动生成代码的配置在pom文件中不生效,问题出在哪里。下面是官方文档的错误产生内容及解决方案和我的部分代码。现在我希望的是pom文件中的配置能够生效,自动生成的Test中separateClassLoader = false。

官方文档https://www.evosuite.org/documentation/measuring-code-coverage/

img

img

img

pom文件

4.0.0 com.coderdream bsTest 0.0.1-SNAPSHOT jar ant-demo http://maven.apache.org UTF-8 1.0.6 src/test/java junit junit 4.8 test org.evosuite evosuite-standalone-runtime ${evosuiteVersion} test org.evosuite.plugins evosuite-maven-plugin ${evosuiteVersion} -Duse_separate_classloader=false prepare process-test-classes org.apache.maven.plugins maven-surefire-plugin 2.17 listener org.evosuite.runtime.InitializingListener org.codehaus.mojo build-helper-maven-plugin 1.8 add-test-source generate-test-sources add-test-source ${customFolder}

ANT build文件

自动生成的一个测试用例

/* * This file was automatically generated by EvoSuite * Wed Apr 12 08:33:13 GMT 2023 */ import org.junit.Test; import static org.junit.Assert.*; import static org.evosuite.runtime.EvoAssertions.*; import org.evosuite.runtime.EvoRunner; import org.evosuite.runtime.EvoRunnerParameters; import org.junit.runner.RunWith; @RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = true, useJEE = true) public class ComplexCalculation_ESTest extends ComplexCalculation_ESTest_scaffolding { @Test(timeout = 4000) public void test0() throws Throwable { ComplexCalculation complexCalculation0 = new ComplexCalculation(); int int0 = complexCalculation0.Multiply(0, 0); assertEquals(0, int0); } @Test(timeout = 4000) public void test1() throws Throwable { ComplexCalculation complexCalculation0 = new ComplexCalculation(); int int0 = complexCalculation0.Multiply((-3998), (-1933)); assertEquals(7728134, int0); } @Test(timeout = 4000) public void test2() throws Throwable { ComplexCalculation complexCalculation0 = new ComplexCalculation(); int int0 = complexCalculation0.Division(1558, (-18696)); assertEquals(0, int0); } @Test(timeout = 4000) public void test3() throws Throwable { ComplexCalculation complexCalculation0 = new ComplexCalculation(); int int0 = complexCalculation0.Division((-1610), 130); assertEquals((-12), int0); } @Test(timeout = 4000) public void test4() throws Throwable { ComplexCalculation complexCalculation0 = new ComplexCalculation(); // Undeclared exception! try { complexCalculation0.Division(1, 0); fail("Expecting exception: ArithmeticException"); } catch(ArithmeticException e) { // // / by zero // verifyException("ComplexCalculation", e); } } @Test(timeout = 4000) public void test5() throws Throwable { ComplexCalculation complexCalculation0 = new ComplexCalculation(); int int0 = complexCalculation0.Multiply((-1610), 864); assertEquals((-1391040), int0); } @Test(timeout = 4000) public void test6() throws Throwable { ComplexCalculation complexCalculation0 = new ComplexCalculation(); int int0 = complexCalculation0.Division((-1610), (-1610)); assertEquals(1, int0); } }


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有