dojo / grunt-dojo2-extras

Grunt tasks and code supporting continuous delivery across projects. Deploys to gh-pages and latest branch.
https://dojo.github.io/grunt-dojo2-extras/
Other
0 stars 6 forks source link

Unit tests #11

Closed devpaul closed 7 years ago

devpaul commented 7 years ago

Unit tests should be created for commands, utils, and tasks. These tests will be ran on every commit.

jacobroufa commented 7 years ago

Yesterday I opened a PR at #17 for the util/environment tests, and started work on the util/Git tests. Spent a bunch of time acclimating to async testing today, but I'm getting the hang of it. My latest is currently in my tests_util_Git branch where I've got 1/2 of the Git tests complete. Thankfully I think I've got the hang of it so I should have the rest of them finished up in the morning and be on to the util/process tests from there. PRs will be submitted as I complete tests for each file.

jacobroufa commented 7 years ago

src/commands tests: 1/7 complete src/util tests: 2/8 complete; 1 pending PR; 1 in progress; 2 (GitHub/Travis) to ignore (for now) tasks tests: 0/5 complete tasks/util tests: 1/2 complete

14 tests left, minus the one on which I'm currently working.


I've started with one of the larger modules to test, so it should be much smoother sailing from here. Hairier modules like initAutomation or api might prove more difficult, but I think I should have this done in three more work days. I am not able to update the Estimate field attached to this issue or I'd put that in there. cc @eheasley

jacobroufa commented 7 years ago

util/Git tests PR submitted at #20.

jacobroufa commented 7 years ago

I worked a bunch today on the util/process tests, but am having issues with the promiseExec and promiseSpawn tests, which essentially proxy promise(exec()) and promise(spawn()), respectively. Since those three methods (promise, exec, and spawn) are covered/tested, do we really need to test these?

Additionally, util/file PR submitted at #21.

jacobroufa commented 7 years ago

I opened PRs today for util/process at #24 and commands/sync at #27. I also started on the util/GitHub tests on my tests_util_GitHub branch; got all of the tests framed up and have more than half of them written so far. I'll finish that first thing tomorrow!

jacobroufa commented 7 years ago

I finished the util/GitHub tests and submitted a PR for it at #30. PRs also open for commands/installDependencies at #29, commands/publish at #31, and util/Travis at #32. Tomorrow I'll finish the rest of the commands tests and start on the commands/initialize tests.

jacobroufa commented 7 years ago

Today I worked on tests for commands/typedoc, commands/decryptDeployKey, and commands/initialize/createDeployKey.

The typedoc tests went smoothly, except that it appears that the methods from our Typedoc class, which extends the TypedocApp (Application) class, do not get called and then call super on the parent class when stubbed out. Rather, the stubbed parent methods are the ones that are directly called. I researched this a bit, but I need to dig some more tomorrow. Other than this single issue, the typedoc tests are complete.

I ran into an issue with both the decryptDeployKey and createDeployKey tests, where methods that I had stubbed that were supposed to mock a chaining api (e.g. encrypt.pipe.on) return undefined in the tests, and so I am not able to properly assert their behavior. createDeployKey tests are otherwise complete, but decryptDeployKey tests need to be finished up after this issue is resolved.

Once I resolve these issues tomorrow, I will finish the rest of the commands/initialize tests and start on the tasks tests.

jacobroufa commented 7 years ago

Tests are complete and PRs submitted, with the following exceptions:

jacobroufa commented 7 years ago

PR submitted for commands/initialize/initDeployment. Only thing holding up this issue now (PR reviews aside) is the config issue present with the three tasks mentioned in my last comment.

jacobroufa commented 7 years ago

PR feedback is all addressed and all remaining tests have been submitted for PR. #41 is giving me issues @devpaul so I will need assistance wrapping that one up. I have mocked the wrapAsyncTask functionality for testing the Grunt tasks directly rather than with a running Grunt instance (as this is for unit, not integration testing) as we talked about. Let me know if you have any questions! 😄

maier49 commented 7 years ago

The existing PRs for this have been merged. The total coverage across all modules is:

--------------------------|----------|----------|----------|----------|
File                      |  % Stmts | % Branch |  % Funcs |  % Lines |
--------------------------|----------|----------|----------|----------|
All files                 |    74.76 |    61.58 |    88.56 |    89.17 |

I'm not sure if we are aiming for a different coverage threshold here than in other Dojo projects but if not we'll need to add some more tests.

devpaul commented 7 years ago

We should take a look and see if anything critical is not covered, but I'm comfortable with this amount of coverage at this time. There are two things that are likely part of the coverage report that we shouldn't really care about

  1. ts boilerplate (because we're not using tslib)
  2. log statements (because testing them is often brittle)

We can create a ticket to increase unit test coverage so we can prioritize it and address it in the future

devpaul commented 7 years ago

Thanks for your help @maier49. I'm going to close this and declare Mission Accomplished since we've merged all of the PRs. If you find something we really need a test against feel free to create a new issue/PR.