Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Organizing fixture preferences for plugin tests

To test an eclipse application I have written a test suite that dynamically discovers available test cases at runtime by searching for test projects stored in a subfolder of a given bundle, looking like this:

my.plugin
  src/      
  fixtures/ 
    p1/     
    p2/

Each fixture is a fully fledged eclipse project. At runtime my suite discovers p1 and p2 and creates a Test for each. Then each test imports its fixture into the workspace on setup, then runs the actual test code and deletes the fixture on teardown. So far this works great, I just dump another fixture to add a new test. No need to write more code for new tests. Yay!

My problem is now that all this runs against a clean workspace with default preferences. What if some of my fixtures need specific preference settings in order to be useful? I somehow would need to provide those custom preferences with the fixture and make sure they are loaded in the test setup for the fixture and restore the default workbench preferences on teardown. What's the best way to do this in eclipse?

like image 371
zedoo Avatar asked Dec 17 '25 18:12

zedoo


1 Answers

I'm not sure if this is the best solution, but I would do something like this:

Let the user choose (in the settings) if the test should be run in a clean workspace or not. If not, just use the current one, so the users can apply settings there. I think this is reasonable, as test running is usually done in the same workspace as the actual project to be tested.

You can access the current workspace by calling ResourcesPlugin.getWorkspace().

like image 153
Cedric Reichenbach Avatar answered Dec 21 '25 01:12

Cedric Reichenbach