How do we know we have enough tests, and that our tests cover all of our code?
Enter simplecov! simplecov is a tool that will measure your test run against the code paths in your code files and see if you're exercising them all. "Code Paths" includes method calls, conditional statements, loops, and anything that branches program flow.
This is important because you want to be able to know that every decision your program makes is being tested, no matter what.
This lab utilizes our Jukebox domain model. We have Jukebox and Song classes. You'll be using the simplecov tool to guide you to write tests that cover 100% of the code in our program.
gem install simplecov.
You should see output at the end of the test results that looks something like:
Coverage report generated for RSpec to /Users/scottreynolds/code/ta/labs/simplecov/coverage. 14 / 33 LOC (42.42%) covered.
coverage/index.htmlin your browser window to view the report. Try to get the coverage to 100% by writing RSpec tests. Every time you add a test, run
rspecto see if the test is passing. Every time you run
rspec, simplecov will also run. Continue to open the
coverage/index.htmlfile after every run to see your updated test coverage. Toggle the individual file view to see which lines are covered by your tests.