Difference between revisions of "How to test unit test infrastructure changes"

From Second Life Wiki
Jump to navigation Jump to search
(New page: .)
 
Line 1: Line 1:
.
== How to test testing? ==
To test testing, you need to write tests. You should write these tests along the different behavior cases to make sure more than the simple case works
 
* Test on an app target
* Test on a library target
* Test on an app target that links the library target
* Test on an app target that uses the library functionality on the component under test
 
You can use trivial code I've prepared that does this, the "chewbacca, what a wookie" project.
 
== [http://www.youtube.com/watch?v=JiN0Y9Mv62w Chewbacca! What a wookie!] ==
 
This implements the above with a library, wookie, which is used in the app, chewbacca. Wookies growl, but a chewbacca can also throw people. It's trivial code that demonstrates the different object boundaries, so I had fun with the names. The CMakeLists.txt files show the important parts - setting up unit tests for the different kinds of circumstances, and verifying the builds work as expected. You can also then test the unit test infrastructure by modifying the code to make cases that should fail.
 
You can get the files from source control here: http://bitbucket.org/poppy_linden/unit-testing-infrastructure-test/ - There's a README.txt that should tell you how to setup. (Short version: copy or symlink the wookie and chewbacca directories into your project's indra/ dir, and add them to the indra/CMakeLists.txt subdirs commands.)
 
== What do I do after that setup? ==
 
To run, you need to configure the build as usual, then build the project "chewbacca". That project should cause the building of
* llcommon (for now)
* llmath (for now)
* PROJECT_wookie_TEST_wookie
* wookie_tests
* wookie (library)
* PROJECT_chewbacca_TEST_person
* PROJECT_chewbacca_TEST_chewbacca
* chewbacca_tests
* chewbacca (application)
 
in that order. If any of those targets aren't built, the unit testing infrastructure doesn't work. Easy!
 
== Additional / manual testing ==
You don't get off scot-free, unless you think the positive case covers everything. We gotta break it! Unfortunately we can't check that in, because then... the build breaks.
 
=== Testing LL_TEST_ADDITIONAL_PROJECTS ===
Open indra/chewbacca/CMakeLists.txt - you should see a bunch of points labeled TEST.
 
More tests forthcoming... (generally, look for the TEST flag in the code and do what it says!)
 
== Write a test from scratch ==
Because this is infrastructure / workflow changing, the documentation needs to be checked. The path starts here: http://wiki.secondlife.com/wiki/Unit_tests - see if you can write a unit test using just that.

Revision as of 15:56, 11 June 2009

How to test testing?

To test testing, you need to write tests. You should write these tests along the different behavior cases to make sure more than the simple case works

  • Test on an app target
  • Test on a library target
  • Test on an app target that links the library target
  • Test on an app target that uses the library functionality on the component under test

You can use trivial code I've prepared that does this, the "chewbacca, what a wookie" project.

Chewbacca! What a wookie!

This implements the above with a library, wookie, which is used in the app, chewbacca. Wookies growl, but a chewbacca can also throw people. It's trivial code that demonstrates the different object boundaries, so I had fun with the names. The CMakeLists.txt files show the important parts - setting up unit tests for the different kinds of circumstances, and verifying the builds work as expected. You can also then test the unit test infrastructure by modifying the code to make cases that should fail.

You can get the files from source control here: http://bitbucket.org/poppy_linden/unit-testing-infrastructure-test/ - There's a README.txt that should tell you how to setup. (Short version: copy or symlink the wookie and chewbacca directories into your project's indra/ dir, and add them to the indra/CMakeLists.txt subdirs commands.)

What do I do after that setup?

To run, you need to configure the build as usual, then build the project "chewbacca". That project should cause the building of

  • llcommon (for now)
  • llmath (for now)
  • PROJECT_wookie_TEST_wookie
  • wookie_tests
  • wookie (library)
  • PROJECT_chewbacca_TEST_person
  • PROJECT_chewbacca_TEST_chewbacca
  • chewbacca_tests
  • chewbacca (application)

in that order. If any of those targets aren't built, the unit testing infrastructure doesn't work. Easy!

Additional / manual testing

You don't get off scot-free, unless you think the positive case covers everything. We gotta break it! Unfortunately we can't check that in, because then... the build breaks.

Testing LL_TEST_ADDITIONAL_PROJECTS

Open indra/chewbacca/CMakeLists.txt - you should see a bunch of points labeled TEST.

More tests forthcoming... (generally, look for the TEST flag in the code and do what it says!)

Write a test from scratch

Because this is infrastructure / workflow changing, the documentation needs to be checked. The path starts here: http://wiki.secondlife.com/wiki/Unit_tests - see if you can write a unit test using just that.