What is run to create code coverage?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

What is run to create code coverage?

Paul Smith

Are the code coverage numbers coming out of the RunAllTests.py?  The Gramps Wiki seems to have very little info about how the numbers are generated and what I need to do to improve them (write more tests, I know but where ;-) ?).

 

Thanks,

Paul DS.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: What is run to create code coverage?

prculley
The code coverage in your emails (and PRs etc.) is being generated by servers in the cloud based on a Travis script (".travis.yml") in the root of our source tree.
You can drill down into the links provided in the coverage report to find lots of details, all the way to individual modules line by line data.

When I want a report locally, for a single module, like when I am developing a test, I use:
nosetests3 --nologcapture --with-cov --cov-config ../.coveragerc gramps/plugins/test/imports_test.py
coverage html --rcfile=../.coveragerc
Which then produces a "htmlcov" directory with a local web site showing much the same as the Travis reports.

I assume, if you are asking the question, that you can use these hints to figure out what to get installed, read the docs on options etc...

As for writing tests, we encourage it!  I usually start by looking at the current test code which is located in many of the directories.  One I wrote, is "gramps/plugins/test/imports_test.py" which does a high level operational test of import modules.  This is not the typical low level function by function test that is generally recommended by test experts, so it may not be the best example.  It does let us know when we do something that causes a change (which may or may not be an error).
I even wrote a wiki entry on how to use it.  https://gramps-project.org/wiki/index.php?title=Test_Imports_module

If you do write a test, pick a place to put it in our tree (typically in one of the 'test' subdirectories).  Make your submission a PR and we will look it over, maybe make suggestions for improvements or changes, and then probably include it into the main code.

Paul C.

On Tue, Feb 20, 2018 at 2:09 AM, Paul Smith <[hidden email]> wrote:

Are the code coverage numbers coming out of the RunAllTests.py?  The Gramps Wiki seems to have very little info about how the numbers are generated and what I need to do to improve them (write more tests, I know but where ;-) ?).

 

Thanks,

Paul DS.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: What is run to create code coverage?

Nick Hall
In reply to this post by Paul Smith
On 20/02/18 08:09, Paul Smith wrote:

Are the code coverage numbers coming out of the RunAllTests.py?  The Gramps Wiki seems to have very little info about how the numbers are generated and what I need to do to improve them (write more tests, I know but where ;-) ?).

The RunAllTests.py script is no longer used.

All our current tests are written using the standard python unittest module and are run using Travis CI.

https://docs.python.org/3.2/library/unittest.html

https://travis-ci.org/

Code coverage is calculated by Codecov.

https://codecov.io/

There is some unit test documentation here:

https://www.gramps-project.org/wiki/index.php?title=Unit_Test_Quickstart

The old documentation, and some notes on the conversion to using Travis CI, can be found here:

https://www.gramps-project.org/wiki/index.php?title=Testing_Gramps

Let us know if you need any help writing unit tests.

Regards,


Nick.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel