다음을 통해 공유


X++ FormAdaptors - An Introduction

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.

In order to describe FormAdaptors, we first need to take a step back to discuss the architecture changes made to enable a web based client that executes against an Azure service in the new AX. The pictures below comparing AX 2012 with the new AX illustrate how the logical control tier has moved to the server. The physical controls, which are now web friendly HTML and JavaScript based, still reside on the client.

clip_image001       >>>>          clip_image002

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..

 

Related:

https://blogs.msdn.microsoft.com/dave_froslie/2016/02/03/achieving-balance-in-testing-software/

https://blogs.msdn.microsoft.com/dave_froslie/2016/02/18/automated-regression-test-qualities/

https://blogs.msdn.microsoft.com/dave_froslie/2016/03/09/test-automation-pyramid/

https://blogs.msdn.microsoft.com/dave_froslie/2016/03/25/testing-is-infinite/