Executing TestNG tests relying on @Parameters from Eclipse

If you wanna run TestNG tests relying on @Parameters like the one below from Eclipse, you need to pass some value for the 'basedir' parameter, otherwise Eclipse will complain:

@Test(groups = "unit", enabled = true, testName = "loaders.bdbje.BdbjeCacheStoreIntegrationTest")
public class BdbjeCacheStoreIntegrationTest extends BaseCacheStoreTest {

  private String tmpDirectory;

  @BeforeTest
  @Parameters({"basedir"})
  protected void setUpTempDir(String basedir) {
     tmpDirectory = basedir + TestingUtil.TEST_PATH + File.separator + getClass().getSimpleName();
  }
...

Having looked around on the web, it’s not clear how to do this and some people even seem to claim that it’s not doable. However, having looked at how Maven deals with this, you simply have to pass the parameter as system property and it will work. So, if you wanna run BdbjeCacheStoreIntegrationTest from Eclipse, simply pass a system property like this:

-Dbasedir=/home/galder/tmp

Otherwise, Eclipse will moan with a message like this:

org.testng.TestNGException:
Parameter 'basedir' is required by @Configuration on method setUpTempDir
Posted by Galder Zamarreño on 2009-06-18
back to top