grunt-build-control icon indicating copy to clipboard operation
grunt-build-control copied to clipboard

Write tests!

Open robwierzbowski opened this issue 11 years ago • 4 comments

This module needs some tests something fierce.

robwierzbowski avatar Feb 01 '14 18:02 robwierzbowski

I don't think there's much value in unit testing this package, since the commands it uses are pretty close to the metal and refactoring is likely to involve different workflows with different git commands. Integration tests are very much needed though.

Test coverage we need:

  • Test project errors out when dist directory doesn't exist/is empty
  • Test creates .git repo
  • Test commit option commits
  • Test commit %tokens% work with custom message
  • Test tag option tags
  • Test push option results in the correct branch and commit when:
    • remote and local branches don't exist
    • remote branch exists, local doesn't
    • remote branch doesn't exist, local does
    • remote and local branches exist
  • Test tags are pushed when tag option is set
  • Test tags aren't pushed when tag option is false
  • Test local and remote history are equal after a run if local is ahead of remote
  • Test local and remote history are equal after a run if local is behind remote
  • Test error if remote and local are out of sync

robwierzbowski avatar Feb 01 '14 23:02 robwierzbowski

I wasn't sure there was any way to run tests that existed in the repo, as they seem to be just place holders, thus I made tests run as scenarios. Check it out on https://github.com/kevinawoo/grunt-build-control/compare/robwierzbowski:master...feature/tests

Let me know what you think, I'm going to be writing more tests in this style as it was easiest for me to understand.

  • [ ] Test project errors out when dist directory doesn't exist/is empty
  • [x] Test creates .git repo
  • [ ] Test commit option commits
  • [ ] Test commit %tokens% work with custom message
  • [ ] Test tag option tags
  • [ ] Test push option results in the correct branch and commit when:
    • [ ] remote and local branches don't exist
    • [ ] remote branch exists, local doesn't
    • [ ] remote branch doesn't exist, local does
    • [ ] remote and local branches exist
  • [ ] Test tags are pushed when tag option is set
  • [ ] Test tags aren't pushed when tag option is false
  • [ ] Test local and remote history are equal after a run if local is ahead of remote
  • [ ] Test local and remote history are equal after a run if local is behind remote
  • [ ] Test error if remote and local are out of sync

kevinawoo avatar Oct 08 '14 23:10 kevinawoo

I've just forked the project, but i'm not able to perform simple grunt jshint. Seem to be some wrong configs in Gruntfile.js:

Loading "nodeunit.js" tasks...ERROR
>> Error: No such module: evals

Running "jshint:all" (jshint) task
Warning: An error occurred while processing a template (Cannot read property 'tests' of undefined)

So, it's totally unclear, if I should respect jshint & tests, while going to make a PR. Should I?

zetorama avatar Apr 28 '15 19:04 zetorama

Ah, yes. I'll need to fix the tests and make some changes to .jshint

For now, you can ignore grunt jshint

kevinawoo avatar Apr 28 '15 20:04 kevinawoo