This week, Brad Wood from Ortus Solutions posted a video to the company YouTube Channel (https://www.youtube.com/watch?v=7k2vXl8FQ24&feature=youtu.be) about some of the new features in TestBox and CommandBox. One was the improved reporting with Testbox from CommandBox and some of the options involved. The other was a brand new feature for CommandBox itself and its integration with TestBox: Testbox Watch.
If you've never used watchers in other tools such as Grunt, the concept is simple. The program "watches" the files in the folder and, when one is changed, it responds in a pre-ordained way. This could be rendering it, running a script or, in this case, running your TestBox test suites.
1. To test it out you need to have the latest version of CommandBox.
If you've never used watchers in other tools such as Grunt, the concept is simple. The program "watches" the files in the folder and, when one is changed, it responds in a pre-ordained way. This could be rendering it, running a script or, in this case, running your TestBox test suites.
1. To test it out you need to have the latest version of CommandBox.
- Open CommandBox
- type upgrade --latest
- You might get the message that you can't upgrade automatically but you will receive the URL to do it manually.
- Install the latest version.
- Open CommandBox to complete the install
2. Make an empty folder by typing "mkdir MyFolder" in CommandBox.
3. Install the latest version of testbox by typing "install Testbox@be" for the bleeding edge version.
4. One step that I think Brad skips in the video is to create a folder called tests in the root of your site and move /testbox/tests/runner.cfm into /tests.
- mkdir tests
- cp testbox/tests/runner.cfm tests/runner.cfm
5. I then created two test cases in the /tests folder
- cd tests
- testbox create bdd test1
- testbox create bdd test2
6. Start the server and get the port for this instance.
- server start
- Copy the URL from the open window
7. Set up your test runner in CommandBox.
- package set testbox.runner=http://127.0.0.1:55938/tests/runner.cfm (change the port to what actually is set).
- package set testbox.verbose=true (or false depending on your mood).
8. Try it from the browser: http://127.0.0.1:55938/tests/runner.cfm - success.
9. Try it from CommandBox.
- testbox run
Again, success. All tests failed (the default tests always fail on purpose so you don't forget to write them).
10. Now, try the watch feature
- testbox watch
2. Edit one of the tests so it passes and save it.
Without having to do anything, the tests were re-run and the passing test shows up in green amidst all of the red text.
Ending Notes:
I almost always have a CommandBox window open these days. Using the watch command takes over the running CommandBox instance so you end up running two instances - one to watch and one to use. Make sure you keep them straight. I ran into a few errors when I started one site from window A and then re-started the same site in Window B. After that snafu, this set up worked well.
Comments
Post a Comment