Diasparsoft Logo Let's write software that people understand.

Home | Contact

Training

JUnit support

Outsourcing

The work that Diasparsoft did for us was outstanding. We are now using the software on a daily basis and their work could well have a dramatic impact on the Reds' organization in the near future.Cincinnati Reds Baseball Club.


Publications

Tips & Tricks

Diasparsoft Toolkit

What is Diaspar?

Interesting Bits RSS

Home » Archives » June 2004 » The same tests at all levels?

[Previous entry: "Recipe: Eclipse doesn't run my tests correctly"] [Next entry: "Introducing "C# for Java programmers""]

06/28/2004: "The same tests at all levels?"


I recently came across a question in the FitNesse users group regarding the various levels of tests. From what I could gather, the questioner was asking about executing the same set of tests as object tests, as integration tests, as system tests. My immediate reaction was "No. The types of tests are just fundamentally different. The types of assertions are just different."

My good fortune is that I was pairing at the time...

My pair partner, Patrick Wilson-Welsh, objected, and within seconds of beginning to get into the details, we decided that it was, indeed, possible. In fact, it could be quite neat.

Imagine an end-to-end test that involves five different collaborators, which I will creatively label A through E. Being an end-to-end test, it's a bit long and has many assertions. How could we execute this test as an object test? In other words, the tests need to be fast and should only test one object at a time.

Here's one way to do it: create a Parameterized Test Case (see JUnit Recipes, recipe 4.8) to externalize those five collaborators into external test fixture data. Now change your suite() method to create (at least) five tests: one that uses a real A with mocks for B-E, one that uses only a real B, then only a real C... you get the idea. It seems like it would work.

Now this doesn't (yet) address the desire to execute exactly the same tests in different modes, but you could execute the default test suite as an end-to-end test, then the customer test suite for object tests. It's not a solution, but it's on the way. I wonder who'll implement this first?