curiouswebster
asked on
Test prep for unit testing
I have not done unit testing for a little while and expect a test upcoming to verify I can quickly write unit tests.
Suggestions of the thing I should be practicing?
Unit tests generate their own mock data, but I doubt a test would include me setting up a mocking framework. I think hard coded lists of objects would be the ideal method, on a coding test.
I assume the object wold be written already for me (it's going to be a 15 minutes test only)
I would create an instance of the object, review the parameter list for that method being tested...
I could create multiple sets of test data. Would a switch statement be appropriate for this kind of knock em out unit test? I could iterate through and handle a handful of test conditions...
Assertions are key.
Once it fails, the unit test fails. I need to be sure the specific test condition which failed the assertion is visible in the console.
Am I approaching this test the right way?
Suggestions?
Thanks.
Suggestions of the thing I should be practicing?
Unit tests generate their own mock data, but I doubt a test would include me setting up a mocking framework. I think hard coded lists of objects would be the ideal method, on a coding test.
I assume the object wold be written already for me (it's going to be a 15 minutes test only)
I would create an instance of the object, review the parameter list for that method being tested...
I could create multiple sets of test data. Would a switch statement be appropriate for this kind of knock em out unit test? I could iterate through and handle a handful of test conditions...
Assertions are key.
Once it fails, the unit test fails. I need to be sure the specific test condition which failed the assertion is visible in the console.
Am I approaching this test the right way?
Suggestions?
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You're very welcome. Just be mindful that these were off the top of my head and unit testing is a huge subject. I'd urge you to do as much reading up on the subject as you can and take from what you read to suit your needs. It's also worth pointing out that some advice can be contradictory as what some engineers consider good practice others may not.
The important thing is to make sure you are testing as much of the code as possible for as many possibilities as possible. Using "Equivalence partitioning" principles is about the best way to do this. There is a lot written about this subject and Google is your friend (and there is plenty of subject matter available that will do the subject way more justice than I ever could - heh).
Good luck with your interview.
The important thing is to make sure you are testing as much of the code as possible for as many possibilities as possible. Using "Equivalence partitioning" principles is about the best way to do this. There is a lot written about this subject and Google is your friend (and there is plenty of subject matter available that will do the subject way more justice than I ever could - heh).
Good luck with your interview.
ASKER
Looking :)
ASKER
:)