petabridge / NBench

Performance benchmarking and testing framework for .NET applications :chart_with_upwards_trend:
https://nbench.io/
Apache License 2.0
533 stars 46 forks source link

Support for config files #70

Closed twenzel closed 8 years ago

twenzel commented 8 years ago

To run my unit tests/benchmark my code is dependent on configurations made in the config file (app.config). Please support loading those files either implicit by the assembly name + ".config" or explicit via CLI argument.

Aaronontheweb commented 8 years ago

@twenzel ah, so you're running the benchmark and the code inside the .DLL depends on values found inside the .config file via ConfigurationManager? Ok - do you know if there's a standard way to do that for a dependent assembly? The NBench.Runner.exe has its own App.config that loads but I don't know about being able to load multiple ones if you catch my drift.

twenzel commented 8 years ago

At the moment I don't know how to do this. May be if the assembly is loaded in a dedicated AppDomain. I'll check the NUnit source because they're supporting this feature.

twenzel commented 8 years ago

@Aaronontheweb You can provide the file name via the ConfigurationFile property on the AppDomainSetup class.

Aaronontheweb commented 8 years ago

@twenzel so would that require loading the test assembly into its own AppDomain?

twenzel commented 8 years ago

Yes. I guess this is the best option. When loading the test assembly into its own AppDomain you have control over the config file, the base path, private bin path, shadow copying. You can also change the target framework version. You can even unload the assembly/appDomain so you can execute multiple benchmarks with different assemblies (even in parallel).

laitang2000 commented 8 years ago

Where can i find the Nbench.runner.exe config? I'm trying to get to an EF connection string in the test. Thanks

Aaronontheweb commented 8 years ago

@twenzel looks like we're going to need to add some AppDomain loading support for this - I don't anticipate this being a huge amount of work.

@laitang2000 should be inside the same folder as the NBench.Runner.exe - if it's not in there you can add one.

Aaronontheweb commented 8 years ago

@twenzel I'm going to be a bit delayed on adding support for that myself - would you like to take a stab at adding it and submitting a pull request?

twenzel commented 8 years ago

Yes, you can assign this issue to me.

Aaronontheweb commented 8 years ago

Closed by #75