How to do Unit Tests for AX 2012 in a Real World Project

Dynamics AX 2012 comes with unit testing support.

To have meaningful tests some test data needs to be provided (stored in tables in the database). To get a reproducable outcome of the unit tests we need to have the same data stored in the tables every time the tests are run. Now the question is, how can we accomplish this?

I learned that there is the possibility of setting the isolation level for the TestSuite to SysTestSuiteCompanyIsolateClass. This will create an empty company and delete the company after the tests have been run. In the setup() method I can fill my testdata into the tables with insert statements. This works fine for small scenarios but becomes cumbersome very fast if you have a real life project.

I was wondering if there is anyone out there with a practical solution of how to use the X++ Unit Test Framework in a real world scenario. Any input is very much appreciated.

As I’m just writing a series of articles about unit testing on my blog, I’m not going to comment on it here in the moment. You should find some answers in the next post in the series. Obviously I won’t be able to cover every little detail in articles intended for beginners.

Thx for your reply - I checked your blog - and I will definitly stay tuned. Your blog is already bookmarked.

If somebody else has some Input - don’t hesitate. Any Information is appreciated very much.

To prepare the company with data for testing in a qualification environment, you could upload data using the Test Data Transfer Tool. With some scripts, you can automate that task.