Serving the Quantitative Finance Community

 
User avatar
samyonez
Topic Author
Posts: 0
Joined: October 7th, 2004, 10:01 am

XLW and NUnit

November 9th, 2010, 12:18 pm

I am looking to build unit tests for my excel addin using NUnit.I am using XLW .net for construction of the addin; the functions take c# native types and XLW types such as CellMatrix. I would like to test the functions that are usually used in Excel via NUnit. This necessitates building an dll that NUnit can test. Both of the two ways i tried to do this have failed:(1) add NUnit reference to the XLL project, and then test myLib.xll directly. Doesn't work as NUnit only recognises dlls, not xlls.(2) Create a new dll, which references the XLL project, and do my NUnit tests in there. I can't ge this to work as i need in myNubitTests.dll to reference xlw, in order that i can write functions that use CellMatrix etc. But i don't know where to find the relevant xlw assembly to reference, or even if this is a good idea.Anyone any experience or advice?Cheers
 
User avatar
Hansi
Posts: 41
Joined: January 25th, 2010, 11:47 am

XLW and NUnit

November 9th, 2010, 12:38 pm

Not familiar with NUnit but could you use it to instance Excel, load the XLL and do the tests within Excel via interop to make sure the plugin definitely works correctly with Excel?
 
User avatar
samyonez
Topic Author
Posts: 0
Joined: October 7th, 2004, 10:01 am

XLW and NUnit

November 9th, 2010, 12:56 pm

thanks for your reply.Yeah, it's reasonably straightforward to build the tests in Excel, but i really wanted to have proper unit tests of my library, with the same interface that excel uses, that i can run from within visual studio & not have to run a bunch of spreadsheets every time.
 
User avatar
Hansi
Posts: 41
Joined: January 25th, 2010, 11:47 am

XLW and NUnit

November 9th, 2010, 3:13 pm

That's what I meant by instancing Excel via Interop. Then you have access to a fully functional Excel item that you can treat as the addin user would but you work with it programmatically , can work with it as a fully functional instance of Excel from Visual Studio and never have to see the UI.
 
User avatar
mj
Posts: 12
Joined: December 20th, 2001, 12:32 pm

XLW and NUnit

November 10th, 2010, 1:07 am

An xll is just a dll with a couple of extra functions, can't you just rename it to .dll ?xlw ships with all its source code.
 
User avatar
AlexesDad
Posts: 11
Joined: May 29th, 2009, 4:10 pm

XLW and NUnit

May 12th, 2011, 2:46 pm

Hi,The current (or iminent) development version of XLW 5 ships with a stub xlcall32.dllThis will allow you load you .xll outside Excel. If build you .xll by decorating your C++functions (those parsed by the InterfaceGenerator) with __declspec(dllexport) then youwill be able to both load up you .xll outside Excel functions and call you C++/C functions.You could do this from a command line console program or any other client you want. Of course if you make a call to the Excel C API from your C++/C functions it wonn't work. The latest dev version can be obtained from here:http://sourceforge.net/projects/xlw/fil ... lw%205DEV/
Last edited by AlexesDad on May 11th, 2011, 10:00 pm, edited 1 time in total.