Reputation: 9049
My setup is like this:
I am writing a Test Adapter for visual studio, that invokes a console application, which loads a test assembly and executes test methods.
The runner works fine, but now I need to be able to Debug tests.
Both my runner and test assembly have their respective .pdb
in the same location.
When the test is launched under debug mode, I am able to see that symbols are loaded.
So, here is some code on what I have been upto:
//load the test assembly
var assembly = Assembly.LoadFrom("path\to\testassembly")
//not actual code, but it is representative
var method = assembly.GetTypes().SelectMany(type => type.GetMethods()).Where(info => info.Name=="foo");
//Create type instance
var instance = Activator.CreateInstance(method.DeclaringType);
method.Invoke(instance, args)
With this, when I put a breakpoint in the method, foo
, Visual studio indicates that symbols have been loaded, and the breakpoint is active. But it never hits it.
And to verify if the method was called, I put some Console.Writeline
s, it does hit the method.
Any tips on how to make it hit the breakpoint?
Upvotes: 0
Views: 512
Reputation: 771
put breakpoint on this line
method.Invoke(instance, args)
when hit, press F11
Upvotes: 1