Problem with file permissions using MBunit/Gallio

I have a test that that uses ConfigurationManager.AppSettings["File"] to read from app.config in .net test project.

Running the tests inside Visual Studio or nant on local machine succeeds. Running the tests in TeamCity with Gallio/MBunit it fails, the value passed is null where ConfigurationManager.AppSettings["File"]. Suggestions?

2 comments
Comment actions Permalink

Could you please check user account that is used for build agent service. Please make sure this is a real local/domain account with administrative rights on the machine.

Could you please check the same app.config is loaded locally and under teamcity.

Thanks!

0
Comment actions Permalink

I don't know how to solve your specific problem, but I would suggest abstracting out your configuration that you use in your tests. You could use a mocking framework or just do it raw. Something like this:

public class IConfiguration
{
     string File { get; set; }
}

public class AppConfigConfiguration : IConfiguration
{
    string File { get { return AppConfig["File"]; } set { AppConfig["File"] = value; } }
}


If you don't use a mocking framework, just implement one inside of your test class:

class FakeConfiguration : IConfiguration
{
    string File { get { return "FakeFile"; } set {} }
}


Hope that helps,

Dan Lash

0

Please sign in to leave a comment.