Git Product home page Git Product logo

minicover's Introduction

minicover's People

Contributors

aib avatar aseduto avatar bhugot avatar day01 avatar exyi avatar ffmathy avatar havocbcn avatar hell-racer avatar higorcesar avatar hugopeters1024 avatar ido-namely avatar illia-m avatar jonjomckay avatar kolesnikov-sergey avatar llatinov avatar lucaslorentz avatar rjha-godaddy avatar zexsm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

minicover's Issues

Could not load file or assembly 'dotnet-minicover'

OS : Windows 10
dotnet versin : 2.0

I do dotnet minicover instrument --workdir bin\Debug\netcoreapp2.0 --sources ......*.cs on template generated project for asp.net core. and I get this error

Unhandled Exception: System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'dotnet-minicover, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
 at .cctor()
 --- End of inner exception stack trace ---

and there is already a dotnet-minicover.dll in output folder.
Although I could not find it in runtimeconfig.json and deps.json files.


I also ran the same thing under wsl in linux and got the same result. Meaning complaining about assembly dotnet-minicover not being found!

Wrong Test method with last Nunit3TestAdapter

Nunit Team added the pdb file in there last release so the Test Method is always from there.
Maybe we should add some filter to eliminate the problem.
Or we ensure tests dll are flag some way even if we don't hit instrument them.

"System.InvalidProgramException : Common Language Runtime detected an invalid program." when running some tests

I'm seeing errors similar to this one since 2.0.0-ci-20180325225037:

Failed   Product.MacroService.Tests.Concept.ConceptServiceTests.GetPersonConceptSummaryTest
Error Message:
 System.InvalidProgramException : Common Language Runtime detected an invalid program.
Stack Trace:
   at Product.MacroService.Concept.Services.ConceptService.<>c.<CalculateConceptFields>b__4_0(Part p)
   at System.Linq.Enumerable.WhereListIterator`1.ToList()
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Product.MacroService.Concept.Services.ConceptService.CalculateImmunizationFields(PersonConceptSummary summary)
   at Product.MacroService.Concept.Services.ConceptService.<GetPersonConceptSummary>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Product.MacroService.Tests.Concept.ConceptServiceTests.<GetPersonConceptSummaryTest>d__4.MoveNext() in /mnt/c/git/product/macroservice/test/Product.MacroService.Tests/Concept/ConceptServiceTests.cs:line 71
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

I'm not sure if it helps, but every failure is with something working with System.Collections.Generic.List or System.Linq.Enumerable.

My development environment is Windows 10/WSL with an up-to-date Ubuntu 16.04 installation. I'm using .NET Core 2.0.0.

"Unhandled Exception: Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly" for referenced package assembly.

I was attempting to instrument code coverage for my persistence tests using:
dotnet minicover instrument --assemblies bin/**/*.dll --sources "../Persistence/**/*.cs"

It resulted in the following output:

Instrumenting assembly "Persistence"
Instrumenting assembly "Persistence"
Instrumenting assembly "Persistence"

Unhandled Exception: Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Nest, Version=6.0.0.0, Culture=neutral, PublicKeyToken=96c599bbe3e70f5d
'
   at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)
   at Mono.Cecil.DefaultAssemblyResolver.Resolve(AssemblyNameReference name)
   at Mono.Cecil.MetadataResolver.Resolve(TypeReference type)
   at Mono.Cecil.Mixin.CheckedResolve(TypeReference self)
   at Mono.Cecil.MetadataBuilder.GetConstantType(TypeReference constant_type, Object constant)
   at Mono.Cecil.MetadataBuilder.AddConstant(IConstantProvider owner, TypeReference type)
   at Mono.Cecil.MetadataBuilder.AddField(FieldDefinition field)
   at Mono.Cecil.MetadataBuilder.AddFields(TypeDefinition type)
   at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type)
   at Mono.Cecil.MetadataBuilder.AddTypes()
   at Mono.Cecil.MetadataBuilder.BuildTypes()
   at Mono.Cecil.MetadataBuilder.BuildModule()
   at Mono.Cecil.MetadataBuilder.BuildMetadata()
   at Mono.Cecil.ModuleWriter.<>c.<BuildMetadata>b__2_0(MetadataBuilder builder, MetadataReader _)
   at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
   at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata)
   at Mono.Cecil.ModuleWriter.Write(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
   at Mono.Cecil.ModuleWriter.WriteModule(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
   at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)
   at MiniCover.Instrumentation.Instrumenter.InstrumentAssemblyIfNecessary(String assemblyFile)
   at MiniCover.Instrumentation.Instrumenter.VisitAssemblyGroup(IEnumerable`1 assemblyFiles)
   at MiniCover.Instrumentation.Instrumenter.Execute()
   at MiniCover.Program.<>c__DisplayClass0_0.<Main>b__1()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at MiniCover.Program.Main(String[] args)

I believe it is related to #6, but the assembly it needs is not in my bin directory, it is instead a referenced nuget package.

Uninstrumenting doesn't work when the same assembly is instrumented in multiple locations

In my solution I have 2 test projects (unit tests and integration tests) that both reference the same main project. Each of the test projects has the same main project assembly in its bin folder. Both copies of the assembly get instrumented, but when I run "dotnet minicover uninstrument" it only uninstruments the main project assembly in one of the test's bin folders.

I think this is because the coverage.json file only has one entry for the assembly, which only tracks the location of one File, BackupFile, etc.

Is There an Elegent Way to configure Exclusions?

Hi there,
Great tool - now coverage is possible on Linux!

The small annoying thing is to configure excluded files. Usually quote a lot of files/infrastrucutre boundaries should be excluded from unit tests - the list is quite large.
Is there a better way to specify exclusion?
Like OpenCover used special file for exclusion?

This is the what I have at the moment (long list..)

--exclude-sources '../src/**/Repositories/*.cs' --exclude-sources  '../src/**/Swagger'  --exclude-sources '../src/**/Data' --exclude-sources '../src/**/Startup.cs'  --exclude-sources '../src/**/Program.cs'  --exclude-sources <more exclusion here>

Thanks!

Problem with async methods

If the class contains async method, the reports are generated incorrectly (opencover, clover, etc)

Example

Async class

using System;
using System.Threading.Tasks;

namespace QnpMiddleService
{
    public class AsyncExample
    {
        public void DoNotAsync()
        {
            Console.WriteLine("Do Not Async");
        }

        public async Task DoAsync()
        {
            await Task.Delay(1);
            Console.WriteLine("Do Async");
        }

        public async Task DoAsyncAnother()
        {
             await Task.Delay(1);
            Console.WriteLine("Do Async another");
        }
    }
}

opencover report

<?xml-stylesheet type='text/xsl' href='coverage.xsl'?>
<CoverageSession>
  <Module hash="353e72eb-ce92-4b3c-ac52-68e0b274e447">
    <FullName>QnpMiddleService</FullName>
    <ModuleName>QnpMiddleService</ModuleName>
    <File uid="1" fullPath="C:\Users\U_M0XZD\Projects\qnp\qnp-middle-service\src\QnpMiddleService\AsyncExample.cs" />
    <Class>
      <FullName>QnpMiddleService.AsyncExample</FullName>
      <Method visited="false" isConstructor="false">
        <Name>System.Void QnpMiddleService.AsyncExample::DoNotAsync()</Name>
        <FileRef uid="1" />
        <SequencePoint vc="0" uspid="1" ordinal="1" sl="10" sc="13" el="10" ec="47" />
      </Method>
    </Class>
    <Class>
      <FullName>QnpMiddleService.AsyncExample/&lt;DoAsync&gt;d__1</FullName>
      <Method visited="false" isConstructor="false">
        <Name>System.Void QnpMiddleService.AsyncExample/&lt;DoAsync&gt;d__1::MoveNext()</Name>
        <FileRef uid="1" />
        <SequencePoint vc="0" uspid="2" ordinal="1" sl="15" sc="13" el="15" ec="33" />
        <SequencePoint vc="0" uspid="3" ordinal="2" sl="15" sc="13" el="15" ec="33" />
        <SequencePoint vc="0" uspid="4" ordinal="3" sl="16" sc="13" el="16" ec="43" />
        <SequencePoint vc="0" uspid="5" ordinal="4" sl="16" sc="13" el="16" ec="43" />
      </Method>
    </Class>
    <Class>
      <FullName>QnpMiddleService.AsyncExample/&lt;DoAsyncAnother&gt;d__2</FullName>
      <Method visited="false" isConstructor="false">
        <Name>System.Void QnpMiddleService.AsyncExample/&lt;DoAsyncAnother&gt;d__2::MoveNext()</Name>
        <FileRef uid="1" />
        <SequencePoint vc="0" uspid="6" ordinal="1" sl="21" sc="14" el="21" ec="34" />
        <SequencePoint vc="0" uspid="7" ordinal="2" sl="21" sc="14" el="21" ec="34" />
        <SequencePoint vc="0" uspid="8" ordinal="3" sl="22" sc="13" el="22" ec="51" />
        <SequencePoint vc="0" uspid="9" ordinal="4" sl="22" sc="13" el="22" ec="51" />
      </Method>
    </Class>
  </Module>
</CoverageSession>

Coverage is wrong for chained constructors

I've noticed chained constructors aren't covered. Here's an example of what is showing up as 0 percent covered.

class A
{
     private int _x;

     public A(int x)
     {
          _x = x;
     }

     public A() : this(0)
     {
     }
}

and

class B : A
{
     public B() : base()
     {
     }
}

parameters as a file

What do you think about yaml/json configuration instead cmd line parameters?
All option will be in the file: source, excludes, workdir, etc

No executable found matching command "dotnet-minicover"

For .net core 2.1.301, cannot execute command - dotnet minicover

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="MiniCover" Version="2.0.0-ci-20180517205544" />
  </ItemGroup>
</Project>

Add a version somewhere

I can't tell what version is running. There is no --version. -h --help don't mention version. Usage doesn't mention version.

Thanks,

Sean

Sonarqube ignores coverage report when splitting jobs

Running unit tests in a job, producing coverage report and saving coverage artifacts:

- git checkout origin/develop
- git merge $CI_BUILD_REF --no-commit --no-ff
- cp -r /tools .
- dotnet restore
- dotnet build
- cd tools
- dotnet minicover instrument --workdir ../ --assemblies test/**/bin/**/*.dll --sources src/**/*.cs
- dotnet minicover reset
- cd ..
- for project in test/**/*.csproj; do dotnet test --no-build $project; done
- cd tools
- dotnet minicover uninstrument --workdir ../
- dotnet minicover opencoverreport --workdir ../ --threshold $COV_THRES
- dotnet minicover report --workdir ../ --threshold $COV_THRES
- cd ..
artifacts:
  name: "coverage-report"
  paths:
    - opencovercoverage.xml
    - coverage-hits.txt
    - coverage.json
  expire_in: 1 hour

Running SQ in another stage (the above files are available as an ls command shows):

script:
  - mono /msbuild/SonarQube.Scanner.MSBuild.exe begin /d:sonar.login=$SONARQUBE_TOKEN /d:sonar.host.url=$SONAR_URL /v:$PROJECT_VERSION /k:$SONAR_PROJECT_KEY /d:sonar.cs.opencover.reportsPaths="opencovercoverage.xml".
  - dotnet restore
  - dotnet build
  - ls -al
  - mono /msbuild/SonarQube.Scanner.MSBuild.exe end /d:sonar.login=$SONARQUBE_TOKEN

Sonarqube reports 0.0% coverage.

This is NOT the case when combining the above jobs in a single one.

Why is that?

System.NullReferenceException in MiniCover.HitServices.TestMethodUtils.HasPdb

Hi,

First: Great Job!

Actually i am experiencing a null reference exception in TestMethodUtils.HasPdb
This is strange, because it works in another WebService without errors.
Unfortunately i am not able to see where exactly the nullref is thrown and why

Is there a "simple" ( :) ) way to run the stuff with debug info?

Could this lambda_method(Closure , IServiceProvider , Object[] ) be a problem?

System.NullReferenceException: Object reference not set to an instance of an object.
         at MiniCover.HitServices.TestMethodUtils.HasPdb(MethodBase methodBase)
         at MiniCover.HitServices.TestMethodUtils.GetTestMethod()
         at MiniCover.HitServices.HitService.MethodContext..ctor(String filePath)
         at MiniCover.HitServices.HitService.EnterMethod(String fileName)
         at Sfb.Comm.MailTransfer.Service.Controllers.HealthController..ctor(ServiceStartUpConfig startUpConf, IOptions`1 mailTransferConfig, IOptions`1 openIdConfig, ILogger`1 logger)
         at lambda_method(Closure , IServiceProvider , Object[] )
         at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass5_0.<CreateControllerFactory>g__CreateController|0(ControllerContext controllerContext)
         at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeInnerFilterAsync>d__14.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeFilterPipelineAsync>d__17.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeAsync>d__15.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.<Invoke>d__6.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at Sfb.Extensions.Mvc.ExceptionMiddleware.<Invoke>d__7.MoveNext()

Integration With SonarQube?

It is possible to use the generated html report along with SonarQube?

According to their guidelines, you can point to a specific hmtl report using some property, but the property value depends on the tool used.

There is no mention for minicover.

Error when using this with NUnit

Getting this error when using minicover with nunit

`Exception System.InvalidOperationException, Exception thrown executing tests in /Users/Jesper/2dv610/Snake-Game/bin/Debug/netcoreapp2.0/Snake-Game.dll
Operation is not valid due to the current state of the object.
   at Mono.Cecil.ModuleDefinition.ReadSymbols(ISymbolReader reader)
   at Mono.Cecil.ModuleReader.ReadSymbols(ModuleDefinition module, ReaderParameters parameters)
   at Mono.Cecil.ModuleReader.CreateModule(Image image, ReaderParameters parameters)
   at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
   at NUnit.VisualStudio.TestAdapter.NavigationDataProvider.CacheNewTypes(String assemblyPath, IDictionary`2 types) in C:\Users\Terje\source\repos\nunit\nunit3-vs-adapter\src\NUnitTestAdapter\NavigationDataProvider.cs:line 85
   at NUnit.VisualStudio.TestAdapter.NavigationDataProvider.GetNavigationData(String className, String methodName) in C:\Users\Terje\source\repos\nunit\nunit3-vs-adapter\src\NUnitTestAdapter\NavigationDataProvider.cs:line 48
   at NUnit.VisualStudio.TestAdapter.TestConverter.MakeTestCaseFromXmlNode(XmlNode testNode) in C:\Users\Terje\source\repos\nunit\nunit3-vs-adapter\src\NUnitTestAdapter\TestConverter.cs:line 144
   at NUnit.VisualStudio.TestAdapter.TestConverter.ConvertTestCase(XmlNode testNode) in C:\Users\Terje\source\repos\nunit\nunit3-vs-adapter\src\NUnitTestAdapter\TestConverter.cs:line 79
   at NUnit.VisualStudio.TestAdapter.NUnit3TestExecutor.RunAssembly(String assemblyPath, TestFilter filter) in C:\Users\Terje\source\repos\nunit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnit3TestExecutor.cs:line 249
NUnit Adapter 3.9.0.0: Test execution complete
No test is available in /Users/Jesper/2dv610/Snake-Game/bin/Debug/netcoreapp2.0/Snake-Game.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.`

Any idea what the issue might be?

Now tested dll is instrumented

From the last change

Change GetSourceRelativePath

Previous code:

if (!path.StartsWith(normalizedWorkDir))
                return null;

            if (!sourceFiles.Contains(path))     <<-- this dissapeared!
                return null;

            return path.Substring(normalizedWorkDir.Length);

New code:

Uri file = new Uri(path);
            Uri folder = new Uri(normalizedWorkDir);
            string relativePath = 
                Uri.UnescapeDataString(
                    folder.MakeRelativeUri(file)
                        .ToString()
                        .Replace('/', Path.DirectorySeparatorChar)
                );
            return  relativePath;

The "this dissapeared" implied that is not returned a null

So the code that call the previous code:

var sourceRelativePath = GetSourceRelativePath(documentGroup.Key.Url);
                    if (sourceRelativePath == null)
                        continue;   <- now the dll tested (outside from code) is not skipped

I think that this is an error because intrumenting the test dll (and other dll's not included in source code) implies code covering the test itself or third party dll's!

some method coverage not right

  • problem :
    some method can't coverage by mincover , but the method has test in ut, i don't know
  • env:
    win10
  • ide:
    vs2017
  • example file:
    XUnitTestProject1.zip
  • example code :
public static class Class1
    {
        public static long? GetInt64WithNull(this IDataRecord record, int index)
        {
            return record.IsDBNull(index) ? (long?)null : record.GetInt64(index);
        }

        public static long? GetInt64WithNull(this IDataRecord record, string name)
        {
            return record.GetInt64WithNull(record.GetOrdinal(name));
        }
    }

[Fact]
        public void TesGetInt64WithIsDBNullCheck()
        {
            var reader = new ListDataReader<Student>(_Students);
            reader.Read();
            var col = "Long2";
            Assert.Equal(2, reader.GetInt64WithNull(col).Value);
            reader.Read();
            Assert.False(reader.GetInt64WithNull(col).HasValue);
            reader.Read();
            Assert.Equal(3, reader.GetInt64WithNull(col).Value);
        }

coveralls.io support

Hi,

Are you planning in implementing coveralls.io support?

It would be useful when using remote build servers in reviewing coverage results.

Thank you.

aseduto

Publish as .NET Core Global Tool

With the upcoming release of dotnet core 2.1 they're introducing global tools. It works like NPM global tools (npm install -g package)

That would a nice alternative way to install MiniCover. So instead of having a tools project you can simply do dotnet install tool -g minicover

Unhandled Exception when running Minicover

dotnet minicover instrument --workdir ../ --assemblies test/**/bin/**/*.dll --sources src/**/*.cs

Instrumenting assembly "C:\dev\ims\SFMC\hubexchangegateway\test\Area.Admin.Tests\bin\Debug\netcoreapp2.0\Area.Admin.dll"

Unhandled Exception: System.Exception: Hash algorithm None is not supported.
   at MiniCover.Extensions.DocumentExtensions.CreateHashAlgorithm(DocumentHashAlgorithm algorithm)
   at MiniCover.Extensions.DocumentExtensions.FileHasChanged(Document document)
   at MiniCover.Instrumentation.Instrumenter.InstrumentAssembly(String assemblyFile)
   at MiniCover.Instrumentation.Instrumenter.Execute()
   at MiniCover.Program.<>c__DisplayClass0_0.<Main>b__1()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at MiniCover.Program.Main(String[] args)

Using xunit for unit tests.

Let me know what additional information you might need or how I can go about debugging this.

Getting 0% coverage in black box tests

env:

  • dotnet core 2
  • linux

I have 2 sets of tests: unit and component. When running unit tests I get code coverage results as expected.

Unfortunately, when running component tests where I spin up our server from within the test, communicate with it via Http, and run assertions based on the request/responses I get 0% code coverage from the results of these tests.

Do you know why this may be and/or a way to get coverage when running this style test?

Getting Ignoring modified file error on F# files

Hi. Trying to Run coverage on F# project. Getting this error on most .fs files:

Instrumenting assembly "Test.Api"
Ignoring modified file "C:\work\source_code\test-api\Test.Api\WebApiSuave.fs"
Ignoring modified file "C:\work\source_code\test-api\Test.Api\Persistence\DataAccess.fs"
Ignoring modified file "C:\work\source_code\test-api\Test.Api\Configurator.fs"
Ignoring modified file "C:\work\source_code\test-api\Test.Api\Common\DomainTypes.fs"

is this some sort of bug, or F# is not supported?

System.BadImageFormatException : Could not resolve field token

I am experimenting with using msbuild and minicover on a Unity project to see if I could generate some coverage data. Without instrumentation, the test run fine, but with the instrumentation I get:

1) TestSelBase.TestSomething : System.TypeInitializationException : The type initializer for '<Module>' threw an exception.
  ----> System.BadImageFormatException : Could not resolve field token 0x0400000a

Let me know if I need to provide more details.

System.NotImplementedException: GenericInst with 2.0.0-ci-20180328123752

Hi,

I am trying to implement this in my pipeline but I am getting:

Unhandled Exception: System.NotImplementedException: GenericInst
at Mono.Cecil.SignatureReader.ReadPrimitiveValue(ElementType type)
at Mono.Cecil.MetadataReader.ReadLocalConstant(UInt32 rid)
at Mono.Cecil.MetadataReader.ReadLocalScope(Row6 record) at Mono.Cecil.MetadataReader.ReadScope(MethodDefinition method) at Mono.Cecil.Cil.PortablePdbReader.Read(MethodDefinition method) at Mono.Cecil.Cil.CodeReader.ReadMethodBody() at Mono.Cecil.Cil.CodeReader.ReadMethodBody(MethodDefinition method) at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TRet& variable, TItem item, Func3 read)
at Mono.Cecil.MethodDefinition.get_DebugInformation()
at MiniCover.Extensions.TypeDefinitionExtensions.<>c.b__1_0(MethodDefinition m)
at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at MiniCover.Extensions.TypeDefinitionExtensions.<GetAllMethods>d__1.MoveNext() at MiniCover.Extensions.TypeDefinitionExtensions.<GetAllMethods>d__1.MoveNext() at MiniCover.Extensions.AssemblyDefinitionExtensions.<GetAllMethods>d__0.MoveNext() at System.Linq.Enumerable.SelectManySingleSelectorIterator2.MoveNext()
at System.Linq.Enumerable.SelectEnumerableIterator2.MoveNext() at System.Linq.Enumerable.DistinctIterator1.MoveNext()
at System.Linq.Enumerable.Any[TSource](IEnumerable1 source, Func2 predicate)
at MiniCover.Instrumentation.Instrumenter.InstrumentAssemblyIfNecessary(String assemblyFile)
at MiniCover.Instrumentation.Instrumenter.VisitAssemblyGroup(IEnumerable`1 assemblyFiles)
at MiniCover.Instrumentation.Instrumenter.Execute()
at MiniCover.Program.<>c__DisplayClass0_1.

b__8()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at MiniCover.Program.Main(String[] args)

Unhandled Exception: System.TypeInitializationException

Publishing the code (dotnet publish), instrumenting it (dotnet minicover instrument) and then running it (dotnet [path to the assembly]) result in:
Unhandled Exception: System.TypeInitializationException: The type initializer for '' threw an exception. ---> System.IO.FileNotFoundException: Could not
load file or assembly 'dotnet-minicover, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
at .cctor()
--- End of inner exception stack trace ---

Looking at the dotnet core the issue maybe could be solved adding the dotnet-minicover.dll to the deps.json file.

Getting reports while app is running?

Is there any way to dump coverage-hits file while application is running?
I am deploying instrumented asp.net core application inside a docker and I want to provide an API that while application is running somehow get the reports and also be able to reset counters.

Is there a way?Or suggestions how to achieve this?

htmlreport fails if directory path doesn't already exist

When executing:
dotnet minicover htmlreport --workdir ../ --threshold 90
I get a DirectoryNotfoundException.

Seems maybe a "CreateDirectory()" in the "WriteFooter()" method before attempting to write out the html file can fix this?

MsBuild integration to simplify instrumenting assemblies

I think it would be nice have integration with MsBuild to simplify assembly instrumenting.

Proposal:

  • Split coverage.json and hits file per assembly, and place them in the assembly folder. So, MyAssembly.dll would have MyAssembly.coverage.json + MyAssembly.coverage.hits. (not sure about the names)
    • Generate files per assembly, at same folder the assembly is. I think the coverage file for each assembly would be similar to the InstrumentedAssembly model we have today.
    • Change reset command to search for all *.coverage.hits files inside folder and delete them.
    • Changes reporting commands to search on a folder for all coverage.json files and read them + hits
    • Change uninstrument command to find all coverage.json, restore assemblies backups and delete coverage.json + hits file
    • Change source files paths inside coverage.json to absolute paths. That would simplify minicover and would allow the assembly and coverage file to be copied to any location without breaking it.
  • Create MiniCover.MsBuild package with MsBuild targets that, right after compile, invoke the CLI tool to instrument the new assembly. I think that assembly + the coverage files will then be automatically copied to all projects that references it.

I think after those changes the experience would be:

  1. Install MiniCover.MsBuild on projects you want to measure coverage.

  2. Run build:

dotnet build
dotnet minicover reset SOLUTION_DIR
dotnet test ...
dotnet minicover report SOLUTION_DIR--threshold 90
dotnet minicover htmlreport SOLUTION_DIR--threshold 90 --source-base-path SOLUTION_DIR/src
dotnet minicover uninstrument SOLUTION_DIR

Maybe we don't need to uninstrument anymore because instrumentation would only happen in DEBUG compilation. So dotnet publish -c Release would not have instrumentation.

Instrumenting assembly error

when run Instrumenting assembly there has throw following error.

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at MiniCover.Instrumentation.CustomAssemblyResolver.SearchDirectory(AssemblyNameReference name, IEnumerable1 directories, ReaderParameters parameters) at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters) at Mono.Cecil.DefaultAssemblyResolver.Resolve(AssemblyNameReference name) at Mono.Cecil.MetadataResolver.Resolve(TypeReference type) at Mono.Cecil.Mixin.CheckedResolve(TypeReference self) at Mono.Cecil.MetadataBuilder.GetConstantType(TypeReference constant_type, Object constant) at Mono.Cecil.MetadataBuilder.AddConstant(IConstantProvider owner, TypeReference type) at Mono.Cecil.MetadataBuilder.AddParameter(UInt16 sequence, ParameterDefinition parameter, ParamTable table) at Mono.Cecil.MetadataBuilder.AddParameters(MethodDefinition method) at Mono.Cecil.MetadataBuilder.AddMethod(MethodDefinition method) at Mono.Cecil.MetadataBuilder.AddMethods(TypeDefinition type) at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type) at Mono.Cecil.MetadataBuilder.AddTypes() at Mono.Cecil.MetadataBuilder.BuildTypes() at Mono.Cecil.MetadataBuilder.BuildModule() at Mono.Cecil.MetadataBuilder.BuildMetadata() at Mono.Cecil.ModuleWriter.<>c.<BuildMetadata>b__2_0(MetadataBuilder builder, MetadataReader _) at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func3 read)
at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata)
at Mono.Cecil.ModuleWriter.Write(ModuleDefinition module, Disposable1 stream, WriterParameters parameters) at Mono.Cecil.ModuleWriter.WriteModule(ModuleDefinition module, Disposable1 stream, WriterParameters parameters)
at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)
at MiniCover.Instrumentation.Instrumenter.InstrumentAssemblyIfNecessary(String assemblyFile)
at MiniCover.Instrumentation.Instrumenter.VisitAssemblyGroup(IEnumerable`1 assemblyFiles)
at MiniCover.Instrumentation.Instrumenter.Execute()
at MiniCover.Program.<>c__DisplayClass0_1.

b__4()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at MiniCover.Program.Main(String[] args)

Using statement in test breaks coverage

Using nunit 3.9.0 and MiniCover (btw really appreciate the work), I am seeing a weird situation where using statement appears to break coverage. Another slightly odd behavior I get is that the test source files are included in the coverage results.

With these tests:

[Test]
public void Test()
{
    var stream = new MemoryStream();
    stream.Dispose();
}

[Test]
public void TestUsing()
{
    using(var stream = new MemoryStream())
    {

    }
}

Report shows Test() lines are covered, but TestUsing() lines are not. Any tests that follow TestUsing() are also not covered, and the source code of classes only exercised by those tests are not covered.

Calling Dispose() directly does not seem to cause this result.

Unhandled Exception: Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'DataExtensions.. when dll is in the directory.

Received this after calling dotnet minicover instrument --workdir ../ --assemblies test/**/bin/**/*.dll --sources src/**/*.cs

Instrumenting assembly "C:\dev\ims\SFMC\hubexchangegateway\test\Area.Journeys.Tests\bin\Release\netcoreapp2.0\Area.Journeys.dll"                               
Instrumenting assembly "C:\dev\ims\SFMC\hubexchangegateway\test\Area.Journeys.Tests\bin\Release\netcoreapp2.0\Common.dll"                                      
Instrumenting assembly "C:\dev\ims\SFMC\hubexchangegateway\test\Area.Journeys.Tests\bin\Release\netcoreapp2.0\DataExtensions.dll"                              
Instrumenting assembly "C:\dev\ims\SFMC\hubexchangegateway\test\Area.Journeys.Tests\bin\Release\netcoreapp2.0\MarketingCloudCommands.dll"                      
Instrumenting assembly "C:\dev\ims\SFMC\hubexchangegateway\test\Area.Journeys.Tests\bin\Release\netcoreapp2.0\Nexxus.MarketingCloud.dll"                       
Instrumenting assembly "C:\dev\ims\SFMC\hubexchangegateway\test\Area.Journeys.Tests\bin\Release\netcoreapp2.0\Nexxus.MarketingCloud.Soap.dll"                  
Instrumenting assembly "C:\dev\ims\SFMC\hubexchangegateway\test\Area.PreferenceCenter.Tests\bin\Release\netcoreapp2.0\Area.PreferenceCenter.dll"               
                                                                                                                                                               
Unhandled Exception: Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'DataExtensions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
'                                                                                                                                                              
   at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)                                                         
   at Mono.Cecil.DefaultAssemblyResolver.Resolve(AssemblyNameReference name)                                                                                   
   at Mono.Cecil.MetadataResolver.Resolve(TypeReference type)                                                                                                  
   at Mono.Cecil.Mixin.CheckedResolve(TypeReference self)                                                                                                      
   at Mono.Cecil.MetadataBuilder.GetConstantType(TypeReference constant_type, Object constant)                                                                 
   at Mono.Cecil.MetadataBuilder.AddConstant(IConstantProvider owner, TypeReference type)                                                                      
   at Mono.Cecil.MetadataBuilder.AddParameter(UInt16 sequence, ParameterDefinition parameter, ParamTable table)                                                
   at Mono.Cecil.MetadataBuilder.AddParameters(MethodDefinition method)                                                                                        
   at Mono.Cecil.MetadataBuilder.AddMethod(MethodDefinition method)                                                                                            
   at Mono.Cecil.MetadataBuilder.AddMethods(TypeDefinition type)                                                                                               
   at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type)                                                                                                  
   at Mono.Cecil.MetadataBuilder.AddTypes()                                                                                                                    
   at Mono.Cecil.MetadataBuilder.BuildTypes()                                                                                                                  
   at Mono.Cecil.MetadataBuilder.BuildModule()                                                                                                                 
   at Mono.Cecil.MetadataBuilder.BuildMetadata()                                                                                                               
   at Mono.Cecil.ModuleWriter.<>c.<BuildMetadata>b__2_0(MetadataBuilder builder, MetadataReader _)                                                             
   at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)                                                                                    
   at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata)                                                                 
   at Mono.Cecil.ModuleWriter.Write(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)                                                 
   at Mono.Cecil.ModuleWriter.WriteModule(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)                                           
   at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)                                                                          
   at MiniCover.Instrumentation.Instrumenter.InstrumentAssembly(String assemblyFile)                                                                           
   at MiniCover.Instrumentation.Instrumenter.Execute()                                                                                                         
   at MiniCover.Program.<>c__DisplayClass0_0.<Main>b__1()                                                                                                      
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)                                                                      
   at MiniCover.Program.Main(String[] args)                                                                                                                    

Looking in the test/bin directory I see that dll in there
image

Can't build the solution using VS

I tried to build the solution with VS 2017 and got the error:
minicover-fails-to-build-vs2017

To solve it I had to add the MiniCover.Tests to the solution, is there a reason to not add it?

Exception when executing in Bitbucket Pipeline

I get the following exception when running in BitBucket Pipelines container (Linux). The commands work on my local Windows machine.

dotnet minicover instrument --workdir ../ --assemblies ../ConnectWiseWebHookGUI//bin//ConnectWiseWebHookGUI.dll --sources ../ConnectWiseWebHookGUI//*.cs --exclude-sources ../ConnectWiseWebHookGUI//obj/**/*.cs
Specify --help for a list of available options and commands.
Unhandled Exception: Microsoft.Extensions.CommandLineUtils.CommandParsingException: Unrecognized command or argument '../ConnectWiseWebHookGUI/Models/ConnectWiseConfig.cs'
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.HandleUnexpectedArg(CommandLineApplication command, String[] args, Int32 index, String argTypeName)
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at MiniCover.Program.Main(String[] args)

System.InvalidOperationException: Sequence contains no matching element

Hello!

When I'm trying use assemby instrumenting with last build (2.0.0-ci-20180325225037) , I've got an error:

Unhandled Exception: 
System.InvalidOperationException: Sequence contains no matching element
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
   at Mono.Cecil.Cil.IlProcessorExtensions.EncapsulateMethodBodyWithTryFinallyBlock(ILProcessor ilProcessor, Instruction firstInstruction, Action`2 insertBeforReturn)
   at MiniCover.Instrumentation.Instrumenter.InstrumentMethod(MethodDefinition methodDefinition, IEnumerable`1 sequencePoints, TypeReference methodContextClassReference, MethodReference enterM
ethodReference, MethodReference exitMethodReference, String[] fileLines, InstrumentedAssembly instrumentedAssembly, String sourceRelativePath, MethodReference hitInstructionReference)
   at MiniCover.Instrumentation.Instrumenter.InstrumentAssemblyIfNecessary(String assemblyFile)
   at MiniCover.Instrumentation.Instrumenter.VisitAssemblyGroup(IEnumerable`1 assemblyFiles)
   at MiniCover.Instrumentation.Instrumenter.Execute()
   at MiniCover.Program.<>c__DisplayClass0_1.<Main>b__8()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at MiniCover.Program.Main(String[] args)

I'm run assemblies instrumenting with this powershell command:

	cd .\tools\CustomProjectName.Tools
	dotnet minicover instrument --workdir ../../ --assemblies **/.\tests/**/bin/**/*.dll --sources ../..//**/*.cs --coverage-file minicover-coverage.json
	dotnet minicover reset
	cd ../..

In version 2.0.0-ci-20180321193925 analysis of code coverage finished successfully

Possible to exclude a file/directory from coverage?

Hi, first of all, this is great work, we definitely need this in .net land!

Is there a way to exclude a file or directory from the coverage metrics? I'm thinking specifically about tool generated code. We're writing grpc services, and want to exclude the codegen'd boilerplate that isn't useful to test.

OpenCover-flavored output does not match the actual OpenCover output

EDIT: I didn't see that this had already been addressed.

I'm looking at MiniCover to replace OpenCover in a CI workflow. I am currently rewriting the OpenCover reports to Cobertura format for use with the Jenkins Cobertura plugin, using an OpenCoverToCoberturaConverter tool.

The MiniCover opencoverreport produces report output that doesn't really look like output produced by OpenCover, and the OpenCoverToCoberturaConverter tool can't process it. In particular, MiniCover produces a report which:

  • has an xsl-stylesheet declaration instead of xml
  • does not contain source elements (Class, File, Method, etc.) as children of parent elements (Classes, Files, Methods, etc.)
  • does not have complexity or coverage metrics on Method elements
  • does not have any Summary elements

I have not found a DTD for OpenCover, but there's an example report at https://github.com/sawilde/opencover/blob/master/samplexml/opencovertests.xml which I think they use for unit tests.

Nuget Error MiniCover.HitServices

After a dotnet restore

Installing MiniCover 2.0.0-ci-20180316074459.
tools.csproj : error NU1101: Unable to find package MiniCover.HitServices. No packages exist with this id in source(s): nuget.org
<ItemGroup> <DotNetCliToolReference Include="MiniCover" Version="2.0.0-ci-20180314234126" /> </ItemGroup>

Was working a few days ago with 2.0.0-ci-20180314234126 (2 days ago) I will use this tell its stable again.

No coverage when using a asp.net core TestServer and integration testing

Hi There!
We are really looking forward for this project and got up and running quite fast.

But we now discovered some odd behavior: When combining minicover with ASP.net Core integration testing based on the TestServer, we get zero coverage in the API controllers. I have created a minimal reproducer:

https://github.com/ghandmann/minicover-reproducer

The "funny" thing here is: When i instrument the DLLs and then start the WebAPI-Project with dotnet run and hit the ndpoints minicover is able to collect coverage. Only when the (sucessfull) integration tests hit the same endpoints, we don't see any coverage.

Do you have any idea, whats going on here? Something wrong with our setup? Or a bug in minicover?

"Failed to resolve assembly, when I use 'instrument' command.

I was attempting to instrument code coverage for my persistence tests using:
dotnet minicover instrument --workdir ../ --assemblies test//bin//.dll --sources src/**/.cs

It resulted in the following output:
Unhandled Exception: Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'NPOI, Version=1.2.1.0, Culture=neutral, PublicKeyToken=null'
at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)
at Mono.Cecil.DefaultAssemblyResolver.Resolve(AssemblyNameReference name)
at Mono.Cecil.MetadataResolver.Resolve(TypeReference type)
at Mono.Cecil.Mixin.CheckedResolve(TypeReference self)
at Mono.Cecil.MetadataBuilder.GetConstantType(TypeReference constant_type, Object constant)
at Mono.Cecil.MetadataBuilder.AddConstant(IConstantProvider owner, TypeReference type)
at Mono.Cecil.MetadataBuilder.AddParameter(UInt16 sequence, ParameterDefinition parameter, ParamTable table)
at Mono.Cecil.MetadataBuilder.AddParameters(MethodDefinition method)
at Mono.Cecil.MetadataBuilder.AddMethod(MethodDefinition method)
at Mono.Cecil.MetadataBuilder.AddMethods(TypeDefinition type)
at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type)
at Mono.Cecil.MetadataBuilder.AddTypes()
at Mono.Cecil.MetadataBuilder.BuildTypes()
at Mono.Cecil.MetadataBuilder.BuildModule()
at Mono.Cecil.MetadataBuilder.BuildMetadata()
at Mono.Cecil.ModuleWriter.<>c.b__2_0(MetadataBuilder builder, MetadataReader _)
at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func3 read) at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata) at Mono.Cecil.ModuleWriter.Write(ModuleDefinition module, Disposable1 stream, WriterParameters parameters)
at Mono.Cecil.ModuleWriter.WriteModule(ModuleDefinition module, Disposable1 stream, WriterParameters parameters) at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters) at MiniCover.Instrumentation.Instrumenter.InstrumentAssemblyIfNecessary(String assemblyFile) at MiniCover.Instrumentation.Instrumenter.VisitAssemblyGroup(IEnumerable1 assemblyFiles)
at MiniCover.Instrumentation.Instrumenter.Execute()
at MiniCover.Program.<>c__DisplayClass0_1.

b__4()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at MiniCover.Program.Main(String[] args)

And configuration in my .csproj is following:

  <ItemGroup>
    <PackageReference Include="DotNetCore.NPOI" Version="1.2.1" />
    .......

NPOI.dll not exist in my test bin folder, and i has tried version: 20180517205544
what should i do ?

Thanks !

Getting System.ArgumentException after upgrade from 20180304114938 version

Hi. Getting this error after upgrading to latest version. Tried to upgrade a week ago it was same. 20180304114938 version works fine.

Unhandled Exception: System.ArgumentException: An item with the same key has already been added. Key: 221395250
   at System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException(Object key)
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at MiniCover.HitServices.HitTestMethod.Read(BinaryReader binaryReader)
   at MiniCover.HitServices.HitTestMethod.Deserialize(Stream stream)
   at MiniCover.Hits.TryReadFromFile(String file)
   at MiniCover.Reports.OpenCoverReport.Execute(InstrumentationResult result, String output, Single threshold)
   at MiniCover.Program.<>c__DisplayClass0_6.<Main>b__13()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at MiniCover.Program.Main(String[] args)

When using "yield" with IEnumerables get error "System.InvalidProgramException : Common Language Runtime detected an invalid program."

On my tests, if the tested method uses the keyword "yield" with IEnumerables it throws this exception:

Error Message:
 System.InvalidProgramException : Common Language Runtime detected an invalid program.
Stack Trace:
   at ServiceFramework.Persistence.LabelIndexHelper.<GeneratePairs>d__0.MoveNext()
...

MiniCover version: 2.0.0-ci-20180329054201

Method sample code:

public IEnumerable<string[]> GeneratePairs(string[] labels)
{
    if (labels == null || labels.Length == 0)
    {
        yield break;
    }

    for (var i = 0; i < labels.Length - 1; i++)
    {
        for (var j = i + 1; j < labels.Length; j++)
        {
            yield return new[] {labels[i], labels[j]};
        }
    }
}

The same code runs with no issues when using "dotnet test" line command.

Out of memory (and time)

The tool is specifically demanding for large number of tests / hits.

I have a project (not yet open source) that has 357 tests so far for about 20 files of code.
These are cryptographic schemes and most tests just use different schemes with different parameters and perform couple thousand encryptions / decryptions.

The tool works, but it consumes 13 Gb of RAM and takes 15 minutes.
I noticed, it happens after instrumentation.
Just when I issue report command (regardless of report type).

My guess is that the way minicover reads its own artifacts is inefficient.
Maybe, it reads a big file large number of times?

Regardless, no reasonable CI will run test coverage consuming 13 Gb and 25 minutes for a medium sized project.
So I suggest we review the way report is generated.

I cannot share my whole project, but I think I can share coverage.json and coverage-hits.txt which happens to be a binary file of size 1 Gb.
Would that help?

UPD: in my coverage.json the last ID is 2048 and the number of lines 27221.

Tests that throws exceptions doesn't record any hits

If a test method throws an exception, the hit lines before the exception was thrown are not recorded on the hits file.
That's because we only write the hits when the method execution finishes, and we don't handle exceptions on our instrumentation.

Extract common Library to enable consumption from other tools

I want to write a Cake addin for MiniCover like the one that exists for OpenCover. I cannot easily instruct users to add MiniCover as a tool as the way cake downloads tools from Nuget is not compatible with the DotnetCliTool package type. I could tell users to create a tools project as instructed in the README and pass that to my addin, but I think an easier solution is if we separate the actual instrumentation and reporting logic from the dotnet cli tool frontend. This would allow me to reference it as a dependency in my package and enable users to get simple coverage with something like:

#addin "Cake.MiniCover"

// ...

Task("Coverage")
    .IsDependentOn("build")
    .Does(() => 
{
    MiniCover(tool =>
        {
            foreach(var project in GetFiles("./test/**/*.csproj"))
            {
                tool.DotNetCoreTest(project.FullPath, new DotNetCoreTestSettings()
                {
                    // Required to keep instrumentation added by MiniCover
                    NoBuild = true,
                    Configuration = configuration
                });
            }
        },
        new MiniCoverSettings()
            .WithAssembliesMatching("./test/**/*.dll")
            .WithSourcesMatching("./src/**/*.cs")
            .GenerateReport(ReportType.CONSOLE | ReportType.XML)
    );
});

// ...

Then, generating coverage becomes as simple as

./build.sh -t Coverage

# Or on Windows:

./build.ps1 -t Coverage

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.