Is it possible to debug a .Net 2.0 custom action? Ideally, I’d like to create an IFBCustomActionExecuteContext object and leverage NUnit to unit test my custom actions. This saves me the step of deploying the assembly into the /ActionDefs/Assemblies/2.0 directory. Worst case, I’d like to attach the Visual Studio debugger to the FinalBuilder process to step into my custom action.
Thanks.
Hi Jeff,
Unfortunately, assemblies have to be inside the Assemblies folder. This is an architectural limitation with the way FB hosts the .NET CLR.
You should be able to attach the managed code debugger to FinalBuilder, though. This is how we debug our own custom action assemblies.
If you want to unit test your custom actions, I suggest making a stub object which implements IFBCustomActionExecuteContext (you won’t be able to instantiate a “real” IFBCustomActionExecuteContext-implementing class without running the action inside FinalBuilder.) You can then write a harness class which calls into your custom action assembly in the same way FinalBuilder does. If you do put together anything like this, it’d be great if you could share it with the FinalBuilder community (let me know if you need more information.) Take a look at the NUnit unit test framework of CruiseControl.NET for an example of this kind of approach (no doubt there are other examples.)
Regards,
Angus
I did discover a method of, from my custom action .Net assembly, referencing a second assembly residing within a directory other than ActionDefs\Assemblies\x.0. For example, FinalBuilder calls into my CustomAction.dll while CustomAction.dll references ScmRepository.dll which resides in the C:\Program Files\ScmRepository directory.
I’m using a .Net Publisher Policy residing within the C:\Program Files\FinalBuilder 5\ directory next to the FinalBuilder5.exe executable. This “tells” FinalBuilder about the ScmRepository.dll assembly without having to move or copy it into the ActionDefs\Assemblies\x.0 directory. I’ve attached an example config screenshot and pasted the XML below (although I expect the editor will mangle it). The config file must be named finalbuilder5.exe.config
I was able to construct a solution which mimics the FinalBuilder Execute Context to enable unit testing with NUnit. It’s not perfect but I created custom classes which implement IFBCustomActionExecuteContext and IFBPropertyStore. I’ve attached a sample project and harness which demonstrates a simple calculator sum operation.
The unzipped .Net 2.0 projects should work without modification assuming you have NUnit 2.2.9 installed to C:\Program Files\NUnit-Net-2.0 2.2.9\bin
Jeff…FinalBuilderUnitTestCustomAction.zip (82.708 KB)
Hi Jeff,
That looks great. If you feel like contributing it, is there any chance you could post it to the Community Downloads page as well?
I realised this morning that another candidate for this approach is NMock. That should let you do things like “expect” certain output or results and fail the tests if they are not provided.
Regards,
Angus