Giter Club home page Giter Club logo

Comments (5)

SteveGilham avatar SteveGilham commented on August 25, 2024

I'm not sure what it is you are actually doing, as dotnet build [solution] takes no notice of the altcover properties; there is no __Instrumented folder after such an operation.

I suspect that what you want to do is use altcover as a command-line tool, as discussed in e.g. the modes of operation wiki page. For this style of operation you can give the path to the altcover binaries in the nuget cache, but it is probably more convenient to either explicitly nuget it to a local folder; or better, use the altcover global tool.

from altcover.

SteveGilham avatar SteveGilham commented on August 25, 2024

With a simple solution like this one
Screenshot 2024-04-09 165040
doing

dotnet test TestProject1.sln --configuration Release --property:AltCover=true --property:AltCoverReportFormat=opencover

gives an error trying to test the console application
Screenshot 2024-04-09 165310
but going to the instrumented folder and running the console application gives
Screenshot 2024-04-09 165436
and the coverage.xml file in the console app project directory contains the obvious visit

        <Class>
          <Summary numSequencePoints="1" visitedSequencePoints="0" numBranchPoints="1" visitedBranchPoints="0" sequenceCoverage="0" branchCoverage="0" maxCyclomaticComplexity="1" minCyclomaticComplexity="1" visitedClasses="0" numClasses="1" visitedMethods="0" numMethods="1" minCrapScore="2" maxCrapScore="2" />
          <FullName>&lt;StartupCode$ConsoleApp1&gt;.$Program</FullName>
          <Methods>
            <Method visited="false" cyclomaticComplexity="1" nPathComplexity="0" sequenceCoverage="0" branchCoverage="0" isConstructor="false" isStatic="true" isGetter="false" isSetter="false" crapScore="2">
              <Summary numSequencePoints="1" visitedSequencePoints="0" numBranchPoints="1" visitedBranchPoints="0" sequenceCoverage="0" branchCoverage="0" maxCyclomaticComplexity="1" minCyclomaticComplexity="1" visitedClasses="0" numClasses="0" visitedMethods="0" numMethods="1" minCrapScore="2" maxCrapScore="2" />
              <MetadataToken>100663298</MetadataToken>
              <Name>System.Void &lt;StartupCode$ConsoleApp1&gt;.$Program::main@()</Name>
              <FileRef uid="36" />
              <SequencePoints>
                <SequencePoint vc="1" uspid="0" ordinal="0" offset="0" sl="2" sc="1" el="2" ec="24" bec="0" bev="0" fileid="36" />
              </SequencePoints>
              <BranchPoints />
              <MethodPoint xsi:type="SequencePoint" vc="0" uspid="0" ordinal="0" offset="0" sl="2" sc="1" el="2" ec="24" bec="0" bev="0" fileid="36" />
            </Method>
          </Methods>
        </Class>

being the results of a run in "classic" mode (just the visit counts filled in, not the summaries); with no filtering, report file also includes the FSharp.Core assembly.

So I'm not sure exactly what it is you were doing; but knowing that it would have to be more than what was specified above, which doesn't even ask for the coverage file to be zipped.

The fix issue #209 will mean that the console program will not be tested, or even instrumented stand-alone; however by going to the instrumented folder under the test program, it is possible to run the instrumented console app, with the results, in this case, going in classic mode to the test project's coverage file.

from altcover.

nmoinvaz avatar nmoinvaz commented on August 25, 2024

So I'm not sure exactly what it is you were doing;

What I was doing was:

  • Adding altcover package to all projects
  • Building in Debug mode (this creates the __Instrumented folder)
  • Trying to run the executables from the __Instrumented folder.

Now, after further research about the Modes of Operation, I realize:

  • I don't have to add altcover package, but instead can use altcover global tool.
  • Build in Release mode
  • Instrument the binaries into a separate folder before running them using global tool.

I think it might have helped me a bit if the Modes of Operation wiki page was clearer to understand somehow but I'm not sure how. But it could also help if there was simple examples of how to use altcover in GitHub Actions or in CI environment.

I've gotten it all running now. Thank you for your help and for your work on this great project!

Please feel free to close this issue if you see that I what I was doing initially is not a supported mode/method of running altcover.

from altcover.

SteveGilham avatar SteveGilham commented on August 25, 2024

Thanks for the comments on the documentation. It's partly a result of the original AltCover (2010-2017) having been a plain .Net Framework application; with the dotnet test integration being a later extension which tries to join in the automatic behaviour of the newer tool, which has in the subsequent years become the default way of doing things rather than something new and exotic.

This is the part that I'm not sure about, and would like to understand before I close the issue

Building in Debug mode (this creates the __Instrumented folder)

because just building shouldn't create that folder.

That requires running the VSTest target, within which the Prepare task that creates that directory is executed, and dotnet build doesn't go near the testing target.
Secondly, to be looking for a zipped coverage file, it would need $(AltCoverZipFile) to have been set to "true", which isn't the sort of thing that happens by accident.

from altcover.

nmoinvaz avatar nmoinvaz commented on August 25, 2024

This is the part that I'm not sure about, and would like to understand before I close the issue

Building in Debug mode (this creates the __Instrumented folder)

I tried to reproduce it but was not able to. I must have been mistaken how that folder was created. Sorry.

from altcover.

Related Issues (20)

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.