Notes from a testing session I ran earlier this year.
Test Driven Development – http://en.wikipedia.org/wiki/Test-driven_development
Unit Testing – http://msdn.microsoft.com/en-us/magazine/cc163665.aspx
QA Plan: http://readyset.tigris.org/nonav/templates/qa-plan.html
Test Cases: http://readyset.tigris.org/nonav/templates/test-case-format.html
eg: Steps to carry out the test. See step formating rules below.
- visit LoginPage
- enter userID
- enter password
- click login
- see the terms of use page
- click agree radio button at page bottom
- click submit button
- see PersonalPage
- verify that welcome message is correct username
Copied from <http://readyset.tigris.org/nonav/templates/test-case-format.html>
- JSUnit: http://www.jsunit.net/
- Use NUnit libraries for implementing unit tests within managed code: http://nunit.org/index.php
- How to write good unit tests: http://www.basilv.com/psd/blog/2006/how-to-write-good-unit-tests
- Test your unit test, ensure your test coverage by changing facets of your code, and ensure that the tests fail
- Make tests easy to run, anyone should be able to check the code out and execute the unit tests without a hitch
- Make sure your errors returned are meaningful
- Use factories for class instantiation in unit tests, otherwise changing a class will ultimately break your tests
- Write reused configuration code in methods for the same reason as above
- Avoid dependencies between tests this can create confusion if they need to be run in a specific order, test isolation is mandatory
- Avoid multiple test assertions in one test, the method will return on the first assert so subsequent test results will remain hidden. It will be easier to diagnose if all the tests are returning results
- Create readable tests with meaningful variable names and comments if needed
-
Avoid partially relevant code in your setup method, unless a member variable is required in EVERY test do not put the member in the initialiser
Sample unit test QA integration:
We will develop and maintain a unit test suite using the NUnit framework. We will consider the boundary conditions for each argument and test both sides of each boundary. Tests must be run and passed before each commit, and they will also be run by the testing team. Each public method will have at least one test. And, the overall test suite will exercise at least 75% of all executable statements in the system.
Key here is that writing a good unit test is not a trivial exercise
0 Responses to “Testing / Unit Testing – Session 1”