Writing Tests for the Markdown Preview Tool
When you tested the todo tool in Testing the Initial CLI Implementation, you wrote something similar to an integration test by compiling the tool and running it in the test cases. This was necessary as all the code was part of the main function, which can’t be tested. For this application, you’ll take a different approach; you’ll write individual unit tests for each function, and use an integration test to test the run function. You can do this now because the run function returns values that can be used in tests.
This means you’re intentionally not testing some of the code that’s still in the main function, such as the block that parses the command-line flags. You don’t have to write tests for that ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access