0

I create a TestNG project in Eclipse, and I use System.getProperty("user.dir") to get the base folder (like "D:\project\selenium") of the project, but when I run the TestNG in the command line, the base folder returns "C:\users\username\", is there any way to solve this question?

meeroslaph
  • 421
  • 3
  • 12
Alex Bruce
  • 533
  • 2
  • 10
  • 23

2 Answers2

1

Probably the issue is that when you run it via command line, your user.dir corresponds to your global user directory (C:\users\username).

Before you run your tests, try to change your current directory to the one where your Eclipse project is hosted (i.e. cd D:\project\selenium). And after that run your tests.

Unfortunately I do not have Windows at hand right now, so can't test it by myself.

meeroslaph
  • 421
  • 3
  • 12
0

A similar issue was fixed in the latest version of the eclipse plugin: https://github.com/cbeust/testng/issues/903

You should try to upgrade the plugin.

juherr
  • 5,640
  • 1
  • 21
  • 63