code-coverage

How to get Cobertura to fail M2 build for low code coverage

 ̄綄美尐妖づ 提交于 2019-12-30 04:31:06
问题 I'm trying to configure my WAR project build to fail if the line or branch coverage is below given thresholds. I've been using the configuration provided on page 455 of the excellent book Java Power Tools, but with no success. Here's the relevant snippet of my project's Maven 2 POM: <build> ... <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> <version>2.2</version> <configuration> <check> <!-- Per-class thresholds --> <lineRate>80<

How to measure Code Coverage in ASP.NET Core projects in Visual Studio?

那年仲夏 提交于 2019-12-30 02:00:05
问题 I want to measure the Code Coverage of my XUnit-Tests in an ASP.NET Core application. The Tooling for .NET Core in Visual Studio 2015 is preview 2 and code coverage does not work so far. The blog post http://dotnetthoughts.net/measuring-code-coverage-of-aspnet-core-applications-using-opencover/ from February shows a workaround by using the command line of open cover. I am looking for a more integrated way inside of Visual Studio. Has anybody heard of a better / more integrated way of

How to measure Code Coverage in ASP.NET Core projects in Visual Studio?

十年热恋 提交于 2019-12-30 01:59:26
问题 I want to measure the Code Coverage of my XUnit-Tests in an ASP.NET Core application. The Tooling for .NET Core in Visual Studio 2015 is preview 2 and code coverage does not work so far. The blog post http://dotnetthoughts.net/measuring-code-coverage-of-aspnet-core-applications-using-opencover/ from February shows a workaround by using the command line of open cover. I am looking for a more integrated way inside of Visual Studio. Has anybody heard of a better / more integrated way of

Excluding abstractproperties from coverage reports

可紊 提交于 2019-12-30 01:39:15
问题 I have an abstract base class along the lines of: class MyAbstractClass(object): __metaclass__ = ABCMeta @abstractproperty def myproperty(self): pass But when I run nosetests (which coverage) on my project, it complains that the property def line is untested. It can't actually be tested (AFAIK) as instantiation of the abstract class will result in an exception being raised.. Are there any workarounds to this, or do I just have to accept < 100% test coverage? Of course, I could remove the

Code coverage of JBoss AS 7 testsuite, using JaCoCo - no data in jacoco.exec files

梦想与她 提交于 2019-12-29 08:16:16
问题 I'm trying to get coverage of JBoss AS 7. Here's my branch: https://github.com/OndraZizka/jboss-as/tree/TS-jacoco When I run mvn clean install -rf testsuite -DallTests -Dcoverage -fae I get (almost) empty jacoco.exec files - just some metadata (size is few bytes). The JVM arg line used is: -javaagent:${jbossas.ts.dir}/target/jacoco-jars/agent/jacocoagent.jar=destfile=${basedir}/target/jacoco.exec,includes=${jboss.home}/modules/**/*,excludes=${basedir}/target/classes/**/*,append=true,output

Cobertura on Tomcat

痞子三分冷 提交于 2019-12-29 05:27:06
问题 I'm trying to apply code coverage using Cobertura. The app is deployed in Tomcat 5, but when I instrument the .class files, the app stops working. This are my steps: Compile the app (This run in tomcat) Instrument the class files. D:\test\cobertura-1.9.4.1\cobertura-instrument.bat --destination D:\test\instrument D:\src\path_to_app\main\target\webapp Overwrite the class files of D:\src\path_to_app\main\target\webapp with the instrumented class files in D:\test\instrument . Deploy the app in

What are the differences between the three methods of code coverage analysis?

一笑奈何 提交于 2019-12-29 03:37:13
问题 This sonar page basically lists the various methods employed by different code coverage analysis tools: Source code instrumentation (Used by Clover) Offline byte code instrumentation (Used by Cobertura) On-the-fly byte code instrumentation (Used by Jacoco) What are these three methods and which one is the most efficient and why?If the answer to the question of efficiency is "it depends" , then please explain why? 回答1: Source code instrumentation consists in adding instructions to the source

JaCoCo returning 0% Coverage with Kotlin and Android 3.0

别说谁变了你拦得住时间么 提交于 2019-12-29 03:33:06
问题 I am trying to check my code coverage for a test case that I wrote in Kotlin. When I execute ./gradlew createDebugCoverageReport --info , my coverage.ec file is empty and my reports indicate that I have 0% coverage. Please note, the test cases are 100% successful. Can anyone think of any reasons my coverage.ec file keeps returning 0 bytes? I have searched everywhere with no luck. apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply

Exclude auto properties from Code Coverage in Visual Studio 2015

两盒软妹~` 提交于 2019-12-28 15:50:10
问题 I just upgraded a bunch of projects to VS2015/C#6. Now MSTest's Code Coverage analysis is reporting that some auto properties aren't covered by unit tests. This wasn't the case in Visual Studio 2013, and I suspect it may be something to do with the new autoproperty features in C#6. Dealing with all the false-positives this generates rather defeats the purpose of the Code Coverage tool as it makes it practically impossible to identify actual code lacking test coverage. We don't want to write

Mocking Java enum to add a value to test fail case

你说的曾经没有我的故事 提交于 2019-12-28 01:49:58
问题 I have an enum switch more or less like this: public static enum MyEnum {A, B} public int foo(MyEnum value) { switch(value) { case(A): return calculateSomething(); case(B): return calculateSomethingElse(); } throw new IllegalArgumentException("Do not know how to handle " + value); } and I'd like to have all the lines covered by the tests, but as the code is expected to deal with all possibilities, I cannot supply a value without its corresponding case statement in the switch. Extending the