We need to expand our test coverage. It would be helpful to do a test coverage analysis to see which parts of the code are currently not being touched by the tests.
| Comment | File | Size | Author |
|---|
We need to expand our test coverage. It would be helpful to do a test coverage analysis to see which parts of the code are currently not being touched by the tests.
| Comment | File | Size | Author |
|---|
Comments
Comment #1
jonathan1055 commentedIn Reduce memory footprint comment #34 I discovered that the automated testing for default time using popup calendar worked fine even though when doing this operation manually it failed. The error was due to function scheduler_date_popup_pre_validate_alter() not being loaded during manual testing but it seems to have been loaded fine during automated testing. This function was in file .edit.inc which is included from scheduler_form_alter()
Is it the case that during automated testing, a call to drupalPost('node/add/page') will use hook_form_alter, do the edit, validation and the save all in one operation and hence the functions loaded when the form was first called are still known when the data is validated? If this is not the case, then how did the automated tests pass?
Understanding this situation will have a bearing on performing the test coverage analysis, hence continuing this discussion here instead.
Comment #2
jonathan1055 commentedThis task still needs to be done for 7.x. It will differ for 8.x, hence I have created a separate issue #2712465: [meta] 8.x-1.x test coverage
Comment #3
legovaerI've been working on some stuff in order to automate a code coverage report for Drupal modules. You can check my work in progress in this branch on github.
In order to see the code coverage report, click on the coverage report badge.
As soon as it's stable, I'll update this ticket. You can already have a good idea on what we have covered so far!
Comment #4
jonathan1055 commentedWOW! That is fantastic! What a brilliant idea. The coloured lines of code make it beautifully easy to view the coverage. This is great work.
I'd like to know more about how you are achieving it, i.e. getting the data from simpletest. This is going to make it so much better, compared to the task of checking manually. Are you intending to share this and make it available to others?
[edit: I have just signed-up on Github, https://github.com/jonathan1055 ]
Comment #5
legovaerNice to see that you appreciate the work. As I stated; this is work in progress. I'm currently developing an easier way to implement this as it would be nice if other module maintainers would adopt this.
This won't be Drupal module as it requires an isolated container to execute the tests. I am using Travis CI in order to analyze our tests.
I will give you an update as soon as I have a clean working version of this "thingy".
Comment #6
legovaerComment #7
legovaerAfter working a few weeks on this one, I finally have a more generalized approach. The latest report can be found here.
Now we need to think about how we're going to integrate this with the drupal.org repository. There's already a DrupalCI issue which I'm working on as well which will eventually cover this #2622922 [meta] Code coverage.
Comment #8
jonathan1055 commentedDouble Wow - this is even better than the first version.
Can you run it against the current 8.x code repository?
Comment #9
pfrenssenThis looks *really* interesting!
Comment #10
legovaerAfter several months of hard work I can now inform you that we have automated code coverage for Scheduler. The last result can be found here.
To keep track of future analyses, check here.
Comment #11
jonathan1055 commentedGood work Levi, thank you. I have just logged in to your test site and will give my feedback via https://www.drupal.org/project/issues/drupal_coverage_core
Comment #12
jonathan1055 commentedI have added a test for the 'touch' feature, where the created date is changed to match the publishing date.
The coverage report showed that in scheduler.cron.inc this was not being tested. Here is the summary as at the committed code without this patch:

The line not being tested is:

Comment #13
jonathan1055 commentedToo busy with the screen grabs I forgot the patch. In addition to the new test I added
REQUEST_TIMEto thestrtotime()calls to ensure that the values will be consistent when checking for equality.Comment #15
jonathan1055 commentedTo show that drupal_coverage_core is doing its stuff, here is the .cron.inc report from a new run I initiated on the Scheduler page of the test site.
The coverage for

_scheduler_publish()has increased from 91.3% (42/46) to 95.6% (44/46)The detail of the code show that

$n->created = $n->publish_onis now covered by automated testing. We got two extra code lines covered (58 and the closing brace 59).The overall score for .cron.inc has increased from 72.5% to 74.1% and the total score for the module has gone up by an amazing 0.32% from 58.04% to 58.40%
Thank you to everyone working on the DCC module! This is going to be a great tool to help evaluate automated testing.
Comment #16
jonathan1055 commentedAdded a test for the lightweight cron - this has been done in 8.x already. This patch does not test the cron admin form (yet) just the urls and the access key.
Comment #18
jonathan1055 commentedI have started to add tests for the integration with Rules module. Here's a patch which tests our four reaction rules, based on the tests we already have in 8.x.
These tests were prompted by changes I was working when looking at a problem with Rules in #2898724: PDOException: Column 'nid' cannot be null and I realised we have no Rules test coverage at 7.x
Comment #20
jonathan1055 commentedOK testing on d.o. at 7.x still needs the old array syntax
array( )and not[ ]Comment #22
jonathan1055 commentedThe new tests pass locally (via web UI and via run-tests.sh). The simpletest log does not have any useful info on what failed, but it seems that $this->admin_user did not get created, due to the scheduler permissions being invalid (which is odd). This implies that the module did not get enabled, so I tracked back and even though there is no error it may be due to the Rules module not being available. This new patch adds Rules as a test dependency in .info
Comment #24
jonathan1055 commentedAargh! Just got hit by #2692407: Test_dependencies are downloaded before applying patches, rather than after (again). The tests for Rules cannot be tested until the change to .info is committed.
Comment #26
jonathan1055 commentedNow with the Rules test dependency committed, here is just the .test additions
Comment #28
jonathan1055 commentedTests added for Rules Conditions
Comment #30
jonathan1055 commentedThird part of the Rules testing - six events
Comment #32
jonathan1055 commentedSome
[ ]got in, from 8.x. Changed back toarray( )Comment #34
jonathan1055 commentedMissed one.
Comment #36
jonathan1055 commentedand again
Comment #38
jonathan1055 commentedNow it's the
list( )which is not valid at php5.3 in the foreach statement.I do need to find a way to test locally with PHP5.3, not 5.5
Comment #41
damienmckennaYou might consider disabling the PHP 5.5 and 5.6 tests, and switching to using PHP 7.1 as the primary test option - it'll help ensure the module is compatible with PHP 7 and PHP 7 tests run faster than PHP 5 ones, so it'll save the DA module too :)
Comment #42
jonathan1055 commentedThanks for the suggestions. Yes I have added a weekly test at 7.x and 8.x running PHP7.1. I do not currently have a local setup where I can test PHP7 and my travis testing on 8.x fails when running PHP7 due to not having PHPunit 6
I would like to be able to test using PHP7 before running patches on d.o., and only then will I change the default test config to PHP7. Or is that irrelevant?
I have removed the 7.x PHP5.3 test though.
Comment #43
damienmckennaI'd still suggest having tests run for PHP 5.3 unless the module's info file specifically requires a newer version, you don't want to accidentally leave in some code that'll break older installs, and there's imho no benefit to running PHP 5.5 or 5.6 given you're also running 7.x, any compatibility bugs with 5.5/5.6 will also show up with 7.x.
Comment #44
jonathan1055 commentedAdded a new test for Non-Enabled types in #3084867-19: Do not check required (un)publish_on date if scheduled (un)publishing is disabled
Comment #45
jonathan1055 commented