Thursday, December 18, 2008

Debug Unit Tests

There was a recent blog post asking whether the debug framework had any unit tests and if so, where we were hiding them. Yes we do have a test suite to help protect against regressions and we hide it in the org.eclipse.jdt.debug.tests plug-in.

The majority of the tests require some implementation of the debug framework to run. We are responsible for the JDT Debugger, which is part of the SDK and implements the majority of the standard debug model. So the tests were designed to use JDT.

Until Dave brought the idea up, I had never thought of anyone using unit tests to help implement their own debugger. The current tests certainly are not set up for this style of development. I think it would be really cool to have a generic testing harness that checks the behaviour of the framework. Users could have the test harness run against their implementations of the debug interfaces/extensions. Perhaps Bug 259145 could evolve into something like that.

3 comments:

  1. Depending on when the tests are done, will help determine how useful they are from seeing how to use an API. If they are developed first and the code afterward to make the test pass, then they become a design document showing how to use each public class or interface.

    If they are developed after the fact and for bug fixing purposes they become less useful in this case, as the code isn't designed to be tested, only certain pieces are.

    http://en.wikipedia.org/wiki/Unit_test

    ReplyDelete
  2. I've had a long-standing ambition to write such a validation framework. I think what we need for starters is a toolkit to allow a test to do things like: execute various run control commands, wait for views to populate, wait for source display to complete, verify that correct data is shown in views, etc. Once we have this toolkit then we could design more meaningful tests, which measure correctness and performance.

    ReplyDelete
  3. One approach to building the test that are a specification would be to build a simple debugger example using Test Driven Development. As the simple example debugger is built then the test created for example are applied back to the org.eclipse.debug.* code. In this manner you provide a testable specification against a concrete example AND provide the base for completing a more comprehensive set of test for the Debug API.

    ReplyDelete