Does anyone know how to implement unit testing using the framework in my Subject line? Or any other framework like NUnit?
I am trying to implement Test Driven Development with my user functions but I can't figure it out since all the programs need to be called from NX.
Any information would be greatly appreciated.
You will need to add a Reference to the .dll. Use the Browse button.
I found it under C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
Obviously your path might be different, but I think that is the .DLL that you need.
Sorry - I didn't understand what you were asking. Is your program a .DLL or a .EXE?
If you build your code as a console application (.EXE), and run it in an environment where all of the required UGII... and UGS... variables are defined, then as soon as it hits GetSession(), you have an NX session in memory - although you will not see NX on the screen anywhere. Then calls to NXOpen routines should work.
If you are trying to run a .dll in the debugger, you might need to Attach to Process, and select the ugraf.exe.
SteveLabout, I don't see how this answers the question about using visual studio unit testing with NX Open.
Compiling the unit test creates a dll, but you cannot attach it to the ugraf.exe process and then run it from NX (ctrl+u) because it does not have an entry point for NX.
So as a work around I added a Main and a GetUnloadOption to the unit test project. This allows me to run it from NX, but then the visual studio test explorer isn't used to run, manage and show the test results.
Does anyone have any better solutions?
Once you have created the unit test project and added your test methods, then close the solution file and open the *.sln file from the NX console window. Modify the test settings as shown below:
Now you can able to run the test successfully (BadFormatImageException will be resolved) by following the above methods.
Unit tests are not required MAIN function to execute the tests. Test Initialize / TestCleanup attributes helps you to initialize the Session or UFSession and unload the libraries.