eastender
eastender

Reputation: 434

nUnit Test function which uses executable path to open a file

I have a function which opens up the help file for the app. The function takes 3 arguments :

ShowHelp(appPath, 1, @"heelp\help.doc")

To test this I created a Resources folder in my test project, added a doc into this folder and supplied the below:

controller.ShowHelp(Application.ExecutablePath, 1, @"Resources\h.doc");

However when I run this thru test driven.net , my executable path is coming back as :

"C:\Program Files\TestDriven.NET 2.0\ProcessInvocation.exe"

Thanks!

Upvotes: 3

Views: 3575

Answers (2)

chrissie1
chrissie1

Reputation: 5029

you should make your path relative.

http://blogs.lessthandot.com/index.php/DesktopDev/MSTech/application-startuppath-and-nunit?highlight=application.startuppath&sentence=

in other words replace the application.executablepath with "/". See blog for more detail.

Upvotes: 1

João Angelo
João Angelo

Reputation: 57658

If you use

Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)

you should obtain the path for the library containing the tests, probably something like (..\bin\Debug), and then you can adapt the other parameters.

Upvotes: 3

Related Questions