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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch test coverage to use Istanbul #5161

Merged
merged 1 commit into from Apr 21, 2015

Conversation

@ErisDS
Copy link
Member

commented Apr 18, 2015

OK, so I'm probably the only person who ever uses our coverage tool, but it's something I make use of heavily when refactoring or writing new components that lend themselves to being tested. I don't employ a minimum coverage level or anything like that - some code needs heavy coverage, some doesn't.

If you checkout this PR and run grunt coverage you'll find that certain important areas of the code base, like the theme helpers, are well tested. Other important areas, like the middleware, are woefully under tested.

The blanket test coverage we are using currently has a couple of issues. 1) I'm not a fan of the html-cov format, I much prefer lcov. 2) any test which failed during the coverage prevented any coverage from being generated at all 3) it was hard to figure out what was failing. So the coverage had been broken for a while and hadn't been fixed. I was commenting out the inclusion of integration locally any time I wanted to check a unit test wasn't missing anything.

Switching over to istanbul means we get lcov by default. It also shows the tests that fail. If you run grunt coverage on this PR you'll notice there are a couple of failing tests* and that doesn't prevent the report being generated, much better 馃憤

* The current suite of tests depends on having certain cleanup tasks run between each suite, which is currently all handled by grunt. When running the tests through istanbul those cleanup tasks don't happen. That and other issues (timing/async things I guess) mean that the tests don't pass reliably. This certainly needs looking at, but it's not high priority.

There is a separate issue about doing something to generate these reports with the travis build here: #2029


closes #4644

  • Switch from using blanket to istanbul
  • Rename some test files for consistency (and so that they will run)

@ErisDS ErisDS force-pushed the ErisDS:test-coverage branch 2 times, most recently from ca1c8cf to 41b0d9f Apr 18, 2015

Switch test coverage to use Istanbul
closes #4644

- Switch from using blanket to istanbul
- Rename some test files for consistency (and so that they will run)

@ErisDS ErisDS force-pushed the ErisDS:test-coverage branch from 41b0d9f to 6d04ead Apr 19, 2015

novaugust added a commit that referenced this pull request Apr 21, 2015
Merge pull request #5161 from ErisDS/test-coverage
Switch test coverage to use Istanbul

@novaugust novaugust merged commit fc142b3 into TryGhost:master Apr 21, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@ErisDS ErisDS deleted the ErisDS:test-coverage branch Apr 22, 2015

@ErisDS

This comment has been minimized.

Copy link
Member Author

commented Apr 22, 2015

Just to document this bit somewhere. With this change you can now run

grunt coverage to generate a coverage report that will live in core/test/coverage/lcov-report/index.html

Open that file in a browser and you'll get a lovely coverage table like this:

So if you're working on an area like the helpers or importer that need good coverage, you can drill down to see any code branches that are missing tests. It doesn't take into account configuration branches like subdirectories which often trip us up, but it is a good start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can鈥檛 perform that action at this time.