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

Reorganized unit test directory structure + updated npm task names #568

Closed
wants to merge 1 commit into from

Conversation

filmaj
Copy link
Contributor

@filmaj filmaj commented Jun 22, 2017

What does this PR do?

This is a proof-of-concept pull request mainly introduction file organizational changes. Please treat this PR as a discussion point, not as something that needs to be mergeable right away. I wanted to get the feedback of the community and PMC on this change before I went ahead with anything.

Ping @purplecabbage, @stevengill, @shazron, @mwbrooks, @devgeeks, @surajpindoria, @imhotep, @dpogue, @kerrishotts, @matrosov-nikita, @goya, @jcesarmobile, @macdonst, @infil00p. If I missed anyone, please pull them in too ;)

The single biggest change, and takeaway, from this PR is that the unit tests under spec-cordova/ and spec-plugman/ are consolidated into a single top-level spec/ directory. The idea behind this change (and hopefully future to come changes) is that there will exist one unit test spec file per javascript source file as a rough rule-of-thumb. Further, the test directory structure should mirror, as closely as possible, the source directory structure. I feel that that is an implied expectation when it comes to unit test file structures. I think possibly one reason why so many integration tests exist in this repository is that that structure right now is not honoured. So, when contributions come in, the typical expectation of "I made a change in src/foo.js, but I don't see a unit test file under spec/foo.spec.js" is broken, and people feel they have to write integration tests to get the kind of test coverage their contribution requires. Hopefully we can break that pattern here and continue to march towards a healthier and faster test suite.

Other than the directory changes, a summary of smaller but also relevant changes:

  • consolidated the differing spec-plugman and spec-cordova jasmine configuration files
  • consolidated all the helper modules (there are three!?) under the top-level spec/ directory: helper.js, helpers.js and common.js. Combining those into one test-helper file is left as an exercise for a future pull request :)
  • changed package.json npm run tasks to better reflect the purpose of the task. In particular, changed npm run jasmine to npm run unit-tests. I also thought of changing the jshint task to be linter, but then decided against it. I am open to hearing opinions on this.
  • related to the last point, now running npm test runs the integration tests as well. They currently take around 400 seconds to run on my machine, but without them right now we cannot guarantee we will have regressions. I am hoping that as we rewrite more and more integration tests into smaller, faster, more focussed unit tests, the integration test times will continue to drop.
  • made some README changes to reflect the change in npm task names, and also fixed the link to the issue tracker :)

What testing has been done on this change?

npm test.

@codecov-io
Copy link

codecov-io commented Jun 22, 2017

Codecov Report

Merging #568 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #568   +/-   ##
=======================================
  Coverage   43.06%   43.06%           
=======================================
  Files          78       78           
  Lines        4361     4361           
  Branches      852      852           
=======================================
  Hits         1878     1878           
  Misses       2483     2483

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d6fcbc3...fc65a18. Read the comment docs.

@filmaj filmaj force-pushed the spec-consolidation branch 2 times, most recently from ffb8300 to fc65a18 Compare June 22, 2017 22:37
@imhotep
Copy link
Contributor

imhotep commented Jun 23, 2017

I support this change. I believe it will make writing tests for new features easier if each source file has a matching spec file and all source/spec folders are mirrored.

@stevengill
Copy link
Contributor

looks good to me. Only thing I would add is updating travis and appveyor as well. They run the integration tests as a separate task currently.

@filmaj
Copy link
Contributor Author

filmaj commented Jun 26, 2017

Thanks for the feedback @stevengill, good point. I've just removed npm run ci and updated travis and appveyor to just run npm test - just like a developer would on their local machine.

Copy link
Contributor

@purplecabbage purplecabbage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

- consolidate spec-cordova/ and spec-plugman/ into a single spec/ dir.
- put jasmine config and helper modules in top-level spec dir.
- changed package.json npm run scripts to reflect purposes of tasks. remove "npm run ci" (dosnt fit in new tasks layout)
- updated readme to reflect package.json npm run script changes.
- update appveyor and travis to just run "npm test" - just like a dev would on their local machine.
@filmaj filmaj closed this Jun 27, 2017
@filmaj filmaj deleted the spec-consolidation branch June 27, 2017 21:22
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.

None yet

5 participants