jediwhale / fitsharp

Functional testing tools for .NET
http://fitsharp.github.io
Other
152 stars 73 forks source link

Alternate assembly folders specified using the command line option -f is not honoured by runner #156

Closed ramprasathdgl closed 5 years ago

ramprasathdgl commented 5 years ago

Hi,

I have been trying to provide the alternate folder path for the assemblies using the commad line opttion -f as shown below

./runner.exe -c suite.config.xml 9999 -f alternateassemblypath1,alternateassemblypath2

The runner searches for the dll specified in the ApplicationUnderTest but on failure does not search the alternate folder paths specified using the command line option -f

Below is my findings on debugging the issue FYI

The runner.exe registers for the System.AppDomain.CurrentDomain.AssemblyResolve event if the command line option -f . The System.AppDomain.CurrentDomain.AssemblyResolve event is fired only when the assembly is failed to load by the API System.Reflection.Assembly.Load .

The Loading of assembly in runner.exe is handle by the fitSharp.Machine.Engine.LoadAssembly method , In this method the assembly is loaded using the .Net API Assembly.LoadFrom instead of System.Reflection.Assembly.Load API as a result the System.AppDomain.CurrentDomain.AssemblyResolve event is not fired and the Assembly resolve handler is not called and the path to the dll is not resolved

jediwhale commented 5 years ago

I'll take a look. That feature was contributed by someone else and I've never used it!

ramprasathdgl commented 5 years ago

Cool, Thanks for looking in to it

jediwhale commented 5 years ago

This is what I found:

The -f option does not provide alternate folders for finding assemblies that you load directly - the assumption is that you know where these assemblies are and will provide the correct path. The -f option is used to provide alternate folders for finding assemblies referenced by the assemblies that you load. I tested this and it works.

e.g. I load an assembly from c:\my\bin by specifying the path c:\my\bin\mycode.dll. This assembly references myutils.dll which is in c:\other\bin, so I use -f c:\other\bin.