JAVA CodeCov | CodeCov 测试主文件和测试文件,如何只检查主文件?
JAVA CodeCov | CodeCov tests both main and test files, How to check only main files?
我有一个文件名 AVLTree.java,为了测试我创建了 AVLTreetest.java 但 codecov 测试了 src/main 80% 和 src/test 0% 文件夹,因此我的分数降低了
这是我的src目录
src
- main->java->avl_java_travis_cli->AVLTree.java
- test->java->avl_java_travis_cli->AVLTreeTest.java
这是codcov中显示的错误,main中80%,test中覆盖率0%,如何解决?
谢谢
build.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="build" name="avl_java_travis_cli">
<property environment="env"/>
<property name="junit.output.dir" value="junit"/>
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.8"/>
<property name="source" value="1.8"/>
<path id="JUnit 4.libraryclasspath">
<pathelement location="C:/Users/ASUS/.p2/pool/plugins/org.junit_4.13.2.v20211018-1956.jar"/>
<pathelement location="C:/Users/ASUS/.p2/pool/plugins/org.hamcrest.core_1.3.0.v20180420-1519.jar"/>
</path>
<path id="Maven Dependencies.libraryclasspath">
<pathelement location="C:/Users/ASUS/.m2/repository/junit/junit/4.13.2/junit-4.13.2.jar"/>
<pathelement location="C:/Users/ASUS/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar"/>
</path>
<path id="avl_java_travis_cli.classpath">
<pathelement location="target/classes"/>
<path refid="JUnit 4.libraryclasspath"/>
<path refid="Maven Dependencies.libraryclasspath"/>
</path>
<path id="run.avl_java_travis_cli.classpath">
<path refid="avl_java_travis_cli.classpath"/>
<path refid="Maven Dependencies.libraryclasspath"/>
</path>
<target name="init">
<mkdir dir="target/classes"/>
<copy includeemptydirs="false" todir="target/classes">
<fileset dir="src">
<exclude name="**/*.launch"/>
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="target/classes"/>
</target>
<target depends="clean" name="cleanall"/>
<target depends="build-subprojects,build-project" name="build"/>
<target name="build-subprojects"/>
<target depends="init" name="build-project">
<echo message="${ant.project.name}: ${ant.file}"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="target/classes" includeantruntime="false" source="${source}" target="${target}">
<src path="src"/>
<classpath refid="avl_java_travis_cli.classpath"/>
</javac>
</target>
<target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
<target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
<copy todir="${ant.library.dir}">
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</copy>
<unzip dest="${ant.library.dir}">
<patternset includes="jdtCompilerAdapter.jar"/>
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</unzip>
</target>
<target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<antcall target="build"/>
</target>
<target name="avl_java_travis_cli">
<mkdir dir="${junit.output.dir}"/>
<junit fork="yes" printsummary="withOutAndErr">
<formatter type="xml"/>
<test name="test.java.avl_java_travis_cli.AVLTreeTest" todir="${junit.output.dir}"/>
<jvmarg line="-ea"/>
<classpath refid="run.avl_java_travis_cli.classpath"/>
</junit>
</target>
<target name="junitreport">
<junitreport todir="${junit.output.dir}">
<fileset dir="${junit.output.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${junit.output.dir}"/>
</junitreport>
</target>
pom.xml
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>avl_java_travis_cli</groupId>
<artifactId>avl_java_travis_cli</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>avl_java_travis_cli</name>
<url>http://cobertura.github.io/cobertura/</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
这在添加 codecov.yml
后解决了问题
我在 github
中创建了 codecov.yml
ignore
- "src/test"
我有一个文件名 AVLTree.java,为了测试我创建了 AVLTreetest.java 但 codecov 测试了 src/main 80% 和 src/test 0% 文件夹,因此我的分数降低了
这是我的src目录
src
- main->java->avl_java_travis_cli->AVLTree.java
- test->java->avl_java_travis_cli->AVLTreeTest.java
这是codcov中显示的错误,main中80%,test中覆盖率0%,如何解决? 谢谢
build.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="build" name="avl_java_travis_cli">
<property environment="env"/>
<property name="junit.output.dir" value="junit"/>
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.8"/>
<property name="source" value="1.8"/>
<path id="JUnit 4.libraryclasspath">
<pathelement location="C:/Users/ASUS/.p2/pool/plugins/org.junit_4.13.2.v20211018-1956.jar"/>
<pathelement location="C:/Users/ASUS/.p2/pool/plugins/org.hamcrest.core_1.3.0.v20180420-1519.jar"/>
</path>
<path id="Maven Dependencies.libraryclasspath">
<pathelement location="C:/Users/ASUS/.m2/repository/junit/junit/4.13.2/junit-4.13.2.jar"/>
<pathelement location="C:/Users/ASUS/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar"/>
</path>
<path id="avl_java_travis_cli.classpath">
<pathelement location="target/classes"/>
<path refid="JUnit 4.libraryclasspath"/>
<path refid="Maven Dependencies.libraryclasspath"/>
</path>
<path id="run.avl_java_travis_cli.classpath">
<path refid="avl_java_travis_cli.classpath"/>
<path refid="Maven Dependencies.libraryclasspath"/>
</path>
<target name="init">
<mkdir dir="target/classes"/>
<copy includeemptydirs="false" todir="target/classes">
<fileset dir="src">
<exclude name="**/*.launch"/>
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="target/classes"/>
</target>
<target depends="clean" name="cleanall"/>
<target depends="build-subprojects,build-project" name="build"/>
<target name="build-subprojects"/>
<target depends="init" name="build-project">
<echo message="${ant.project.name}: ${ant.file}"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="target/classes" includeantruntime="false" source="${source}" target="${target}">
<src path="src"/>
<classpath refid="avl_java_travis_cli.classpath"/>
</javac>
</target>
<target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
<target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
<copy todir="${ant.library.dir}">
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</copy>
<unzip dest="${ant.library.dir}">
<patternset includes="jdtCompilerAdapter.jar"/>
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</unzip>
</target>
<target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<antcall target="build"/>
</target>
<target name="avl_java_travis_cli">
<mkdir dir="${junit.output.dir}"/>
<junit fork="yes" printsummary="withOutAndErr">
<formatter type="xml"/>
<test name="test.java.avl_java_travis_cli.AVLTreeTest" todir="${junit.output.dir}"/>
<jvmarg line="-ea"/>
<classpath refid="run.avl_java_travis_cli.classpath"/>
</junit>
</target>
<target name="junitreport">
<junitreport todir="${junit.output.dir}">
<fileset dir="${junit.output.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${junit.output.dir}"/>
</junitreport>
</target>
pom.xml
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>avl_java_travis_cli</groupId>
<artifactId>avl_java_travis_cli</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>avl_java_travis_cli</name>
<url>http://cobertura.github.io/cobertura/</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
这在添加 codecov.yml
后解决了问题我在 github
中创建了 codecov.ymlignore
- "src/test"