Giter Club home page Giter Club logo

sg.codecoverage's Introduction

SG.CodeCoverage

A code coverage library, used for Test Impact Analysis (or Continuous Testing) in our internal testing framework, as a replacement for vstest's inefficient data collectors.

How does it work?

SG Coverage works by weaving IL codes into project's assemblies using its Instrumenter type in the SG.CodeCoverage project. It injects a AddHit(int typeId, int methodId) method call that counts number of times the method visited, and creates a json map file that maps id of assemblies, types and their methods to their file paths, during this process.

The AddHit(int, int) method resides in the SG.CodeCoverage.Recorder project, which is an auto generated assembly for each instrumentation phase (inspired by AltCover, Coverlet and MiniCover) and holds the total number of types instrumented and an in-memory visit counter.

Steps to produce coverage results

  1. Instrument assemblies using Instrumenter class. This process outputs a json map file.
  2. When any method in the project is called, instrumented assemblies make sure that the RecordingControllerServer is running and collecting data, and then sends the hit records to the server.
  3. After running each test, you can call RecorderControllerClient.SaveHitsAndReset(string outputPath). This will send a request to server to save the visited types and methods as a binary file like hits.test1.bin, then resets the counter.
  4. After collecting test hits, you can find the visited files by merging the json map file and the binary hit file. This can be easily done using DataCollector.GetVisitedFiles method which does this task.

Summary

This is not exactly a sequence diagram, but helps you get the idea, And as they say, "a picture worth a thousand words":

summary

sg.codecoverage's People

Contributors

prodehghan avatar avestura avatar 01shadowalker01 avatar

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.