I've read that I should be writing the simple, basic tests first and gradually moving up to the harder ones. What tests (in order) should I be writing for the following function?
function List.syncWithList(lst)
lst
lst
lst
lst
You have your basic list of tests. You just provided them to us. At a bare minimum, you should test that every functional requirement has been met (for example, the four points you gave us in the question).
Adding to that are the edge cases, things like empty lists (on one and both sides), identical lists and so forth.
The simplest way to start is to add the following:
and then add more as you strike individual problems.
And I cannot stress this enough: automate your testing! You will find that testing is a lot easier when you can just press a button and look over the results. Every time you strike a bug, add a test which would have caught that bug to the test suite above and press the button to verify it.
We have our testing down to a fine art. With one command, an entire process is put into place which blows away databases, loads them up with known data, runs our tests, compares the output with previous successful tests and so forth.
If we had to do all that manually whenever we made a change, we'd soon toss in the whole idea. By automating everything, testing is a breeze.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With