(888) 685-3101 ext. 2

Unit Testing Saleslogix (now called Infor CRM) is possible and easy to set up with the recent improvements to the OpenSlx library. The SlxAppSetup class is what you need to initialize the Saleslogix framework and enable you to use EntityFactory, SessionScopeWrapper etc from the Saleslogix libraries. Very useful for automatically validating changes to your custom code, and also when you are trying to figure out the syntax for an NHibernate query without having to restart SlxClient over and over.

This is what you need to start testing your business rules using NUnit:

  1. Download and compile OpenSlx from github. You’ll probably need to adjust the references to point to a deployed Saleslogix site.
  2. Download NUnit, I also recommend TestDriven.Net for running tests easily from Visual Studio, make sure you use the last version of both tools. Note that I was not able to run them using the regular NUnit test runner, probably due to the way the reference assemblies are getting copied as part of the test run.
  3. Create your unit test assembly in Visual Studio. Add a reference to your business rules assembly, NUnit, OpenSlx, and some Saleslogix libraries (which can be found on a deployed Saleslogix site). You’ll also want a reference to your custom Sage.Entity.Interfaces.dll which is under the Modeldeployment folder. One tricky part here is you do need references to the correct SLX libraries or the test suite setup will fail and the message in the Visual Studio test runner will not be extremely useful (you can get a better message by testing with the debugger, though)
  4. If you are doing business rules using code snippets, you have to add a reference to that project, located somewhere under your Saleslogix build path.
  5. Create a TestSuiteSetup class. This needs to be in the same namespace as your unit test, this way its Setup and Teardown methods will run before and after each of your tests respectively.
  6. You can now right click to run your unit tests from within Visual Studio:
    Testdriven-Menu

I uploaded a sample test project. Feel free to use it as a base, just adjust the references to match your environment.

Share This