Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port tests to Test2 and improve coverage #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jjatria
Copy link
Contributor

@jjatria jjatria commented Oct 4, 2018

This is an attempt at addressing the issues raised in #9. In particular, that to test random data it is more efficient to control the random seed than to iterate multiple times over the different paths.
As a baseline, this is what dzil cover reported before the changes in this branch:

All tests successful.                                                                                                
Files=12, Tests=30028, 16 wallclock secs ( 1.75 usr  0.23 sys + 15.38 cusr  0.27 csys = 17.63 CPU)                   
Result: PASS                                                                                                         
cover                                                                                                                
Reading database from /home/user/Data-Random/.build/0JJiU2UsDp/cover_db                                 
                                                                                                                     
                                                                                                                     
----------------------------------- ------ ------ ------ ------ ------ ------                                        
File                                  stmt   bran   cond    sub   time  total                                        
----------------------------------- ------ ------ ------ ------ ------ ------                                        
blib/lib/Data/Random.pm               94.7   77.5   36.2  100.0   99.8   76.1                                        
blib/lib/Data/Random/WordList.pm      97.7   58.3   36.3  100.0    0.1   82.6                                        
Total                                 95.3   75.4   36.2  100.0  100.0   77.1                                        
----------------------------------- ------ ------ ------ ------ ------ ------

And after

All tests successful.                                                                                                
Files=12, Tests=21,  4 wallclock secs ( 0.05 usr  0.01 sys +  3.92 cusr  0.20 csys =  4.18 CPU)                      
Result: PASS                                                                                                         
cover                                                                                                                
Reading database from /home/user/Data-Random/.build/LG4WKgKnS4/cover_db                                 
                                                                                                                     
                                                                                                                     
----------------------------------- ------ ------ ------ ------ ------ ------                                        
File                                  stmt   bran   cond    sub   time  total                                        
----------------------------------- ------ ------ ------ ------ ------ ------                                        
blib/lib/Data/Random.pm               99.4   89.8   57.8  100.0   86.7   86.7                                        
blib/lib/Data/Random/WordList.pm      97.7   58.3   45.4  100.0   13.2   84.0                                        
Total                                 99.1   86.3   56.6  100.0  100.0   86.2                                        
----------------------------------- ------ ------ ------ ------ ------ ------  

Although test coverage was high before, the suite took ~16 seconds to run on my machine. The new test suite takes a quarter of the time, and covers a little more code.

As an added bonus, the process of checking the different branches revealed a bug in rand_set() which meant that, calling it in scalar context, it would return an array of references rather than an array reference.

This changes use Test2::V0, but some of the tests still use Test::More. I'm not entirely sure how these tests should be ported, but this can be done separately, before the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant