In recent posts I've mentioned some testability features in AX'7' that have significantly improved our regression test qualities (https://blogs.msdn.microsoft.com/dave_froslie/2016/02/18/automated-regression-test-qualities/). The foremost of these features is the addition of X++ FormAdaptors to use for server side execution of form tests.
Since the form logic is now running on the server, we have the opportunity to execute form based tests on the server.
But why would we want to do this? Don't we want tests to replicate exactly what the customer does with the product? To do that, you would want to exercise the full product stack starting with the physical control on the client… right?
Well… I can't put it any other way… that's wrong. And if you don't understand why, you should go back and read the posts that are linked at the end of this post. But let me summarize why we want to do this:
- Server side form based tests are 10X to 100X faster than client side tests. Our form based test times are now measured in seconds (at most) whereas AX 2012 client side tests were measured in minutes.
- Server side form based tests are much more reliable as the number of moving parts in the test interface is drastically reduced.
- Because of the previous two bullets, it is easier to write more granular tests that are more precise, simpler, and more maintainable.
- Replicating what the customer does with the product is frequently not the best way to write a regression test that supports the engineering team.
- Writing test code in the same language and environment as the product code is a win for engineering productivity.
Now that I've justified why we want form based server side tests, we still need to author these tests. This is where FormAdaptors come into play. The adaptor pattern "is a software design pattern that allows the interface of an existing class to be used from another interface." (https://en.wikipedia.org/wiki/Adapter_pattern). FormAdaptors provide an API for test classes to interact with the form and its controls in a natural, strongly typed way. Under the covers, the API interacts with the form layer on the server ("Logical control" in the picture above) to replicate what a user working with the product in a browser would do.
In summary… I guess I wasn't very precise in my opening paragraph. FormAdaptors are really just a wrapper around the big change in testability - the capability to run fast and reliable server side tests written in X++. FormAdaptors are the 'face' of this capability and make it easier to use, which is an important facet of test development as well! More about the FormAdaptor APIs in future posts..