app.config files are ignored by NUnit 3.0 Test Adapter

1,566 views
Skip to first unread message

Olga Boiarshynova

unread,
Apr 9, 2015, 12:08:20 PM4/9/15
to nunit-...@googlegroups.com
Hi all,

I searched this group and Internet but cannot find solution for my problem. Sorry if question is duplicate.

The Problem: 
If test methods are executed from VS using NUnit 3.0 Test Adapter execution fails  on attempt to access AppSettings in project's config file:
string browserType=ConfigurationManager.AppSettings["browserType"].ToString();

According to NUnit documentation I called config file for HeadlessExecution.dll project HeadlessExecution.dll.config(this file is also copied to bin\Debug\ folder )
Unfortunatelly Test adapter don't use it.

In the same time, I can sucessfully execute all test using nunit-console if I run HeadlessExecution.nunit project:
<NUnitProject>
  <Settings activeconfig="Debug"/>
  <Config name="Debug" binpathtype="Auto" configfile="HeadlessExecution.dll.config">
    <assembly path="bin\Debug\HeadlessExecution.dll" />
  </Config>
  <Config name="Release" binpathtype="Auto" configfile="HeadlessExecution.dll.config">
    <assembly path="bin\Release\HeadlessExecution.dll" />
  </Config>
</NUnitProject>

Environment:
VS 2012
.net-4.5
NUnit 3.0
NUnit 3.0 test adapter

Would you be so kind to help me make NUnit Test adapter work with my app.gonfig file?

Thanks in advance!

-
Best regards,
Olga

Charlie Poole

unread,
Apr 9, 2015, 12:25:13 PM4/9/15
to NUnit-Discuss
Does the standard .dll.config file work for you as well when using
NUnit-Console?
> --
> You received this message because you are subscribed to the Google Groups
> "NUnit-Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nunit-discus...@googlegroups.com.
> To post to this group, send email to nunit-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/nunit-discuss.
> For more options, visit https://groups.google.com/d/optout.

Olga Boiarshynova

unread,
Apr 10, 2015, 4:23:33 AM4/10/15
to nunit-...@googlegroups.com
Standart .dll.config works for me using NUnit-console only if I execute .nunit project. If I execute .dll it fails too.

четверг, 9 апреля 2015 г., 19:25:13 UTC+3 пользователь charlie написал:

Olga Boiarshynova

unread,
Apr 14, 2015, 8:24:44 AM4/14/15
to nunit-...@googlegroups.com
Hi all,

While trying to solve the issue with config file I found that NUnit 3.0 Test adapter uses vstest.console.exe.config as config file for my project instaed of dll.config.
This seams very strange for me because I have no references to VSTest in my test project.

this is how I found it:
 Configuration config= ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
 config2.FilePath property has value  "C:\\PROGRAM FILES (X86)\\MICROSOFT VISUAL STUDIO 11.0\\COMMON7\\IDE\\COMMONEXTENSIONS\\MICROSOFT\\TESTWINDOW\\vstest.console.exe.config"

If I add content of appSettings section from my .dll.config to this vstest.console.exe.config all tests are executed successfully from VS2012 using NUnit 3.0 test adapter.
But as I see, it's not the right way to solve the problem with .config file

Would you be so kind to help me make NUnit 3.0 TestAdapter use dll.config instead of vstest.console.exe.config?

thanks in advance!

пятница, 10 апреля 2015 г., 11:23:33 UTC+3 пользователь Olga Boiarshynova написал:

Olga Boiarshynova

unread,
May 20, 2015, 5:17:59 AM5/20/15
to nunit-...@googlegroups.com
Hi all,

I found workaround for problem described above.
I added the following statement to  [OneTimeSetup] method of assembly Setupfixture:
  AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE",String.Format("{0}\\app.config",AppDomain.CurrentDomain.BaseDirectory));

If you know other way to solve this problem please share with me.

-
Best regards,
Olga

вторник, 14 апреля 2015 г., 15:24:44 UTC+3 пользователь Olga Boiarshynova написал:

Mukesh K

unread,
Sep 28, 2015, 2:19:32 PM9/28/15
to NUnit-Discuss
Hi Olga,

I face the same issue as yours. I remember that there is a place in Nunit.project to change the App.Config file path.
I did that and it worked like a charm.

Olga Boiarshynova

unread,
Oct 1, 2015, 4:03:41 AM10/1/15
to NUnit-Discuss
Hi Mukesh,

Thanks for your responce! 

-
Best regards,
Olga

понедельник, 28 сентября 2015 г., 21:19:32 UTC+3 пользователь Mukesh K написал:
Reply all
Reply to author
Forward
0 new messages