Giter Site home page Giter Site logo

cobbal / swift-package-coverage Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bscothern/swift-package-coverage

0.0 1.0 0.0 44 KB

A tool to simplify gather code coverage for swift packages.

License: MIT License

Shell 0.81% Swift 93.45% Makefile 5.74%

swift-package-coverage's Introduction

swift-package-coverage

A utility that runs runs tests on a swift package and gathers the coverage data.

Usage

Inside your swift package run the command:

swift package-coverage

By default this will create output like this finding coverage of typical source file locations:

   Covered: 1451
     Total: 1936
Percentage: 74.9483

Where the Covered and Total are the number of lines found in the package. If this isn't what you want or you need to customize paths or your build you can see all the options by running:

swift package-coverage --help

Installation

Manual:

git clone https://github.com/bscothern/swift-package-coverage
cd swift-package-coverage
make install

Code Coverge Issues

The llvm-cov files do not always mark when a deinit is called during testing. This results in them always having 0% code coverage even if they run. Xcode will also show this if you go to the coverage report despite the in file code coverage mechanism showing that it is covered. So your code coverage will likely be lower than you expect if you are testing your deinits. If this is happening then you can move all of your deinit logic out into another function and call it in your deinit. It will then correctly gather coverage for that function even if it still fails to do so for the traditional deinit.

Development Tips

When testing with SwiftPM you will need to use the command: swift run --disable-sandbox package-coverage [package-coverage arguments]. If you don't disable the sandbox then the swift test --enable-code-coverage command will fail more often than not. Even with the --enable-code-coverage sometimes a build will fail so in that case just run again.

swift-package-coverage's People

Contributors

bscothern avatar cobbal avatar

Watchers

 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.