Learn how to record, correlate and run a Microsoft Dynamics NAV performance testing scenario without writing a single line of script.
In this video, we will learn how to record and configure a script for load testing Microsoft Dynamics NAV. This application is usually one of the most difficult to correlate. I will show you how to correlate a test script without writing a single line of code, using StresStimulus. We will use the Comprehensive Correlation Method. For each dynamic value in the request, an extractor and one or several parameters will be created. I begin by recording a test case. In the recording wizard I enter a test case name: NAV-sales invoice. Then I enter the URL and the first transaction name, which is: Login. Start recording. Open the dashboard page. Enter the next transaction, "Action Sales Invoice" into the recorder. Click "Actions" and then "Sales invoice". Select the Customer Number from the drop-down. Choose the Item Type and the Item Number. Enter Quantity and Unit Price. Then close the invoice and stop recording. Back in the test wizard, I am removing all unnecessary hosts that were targeted. Then I remove static image requests that are unimportant for performance. Under authentication, I enter the credentials to my NAV account. Then I click "Next" to run "Verify" which will replay the test case one time to check for correlation issues. I got 14 warnings. Let's examine the first one. The recorded session on the left is compared with the replayed session on the right. I switched to the response tab. There are some errors in the response. We need to correlate the script to fix them. I right-click on the first warning and select "Highlight non-correlated dynamic values". I will use the double recording technique to pinpoint dynamic values. To do so, I need to record the same test case again. The Test Wizard will appear again, but the fields are prefilled, so just keep clicking "Next". Let's fast forward. I recorded the same test case a second time. Now when I go back and select "highlight dynamic values," the test case and the session that I need to compare are automatically selected. All values that are different in the first and second recording are already highlighted. After correlating many Dynamics NAV test scenarios, we learned that we should only correlate hexadecimal values that have a length between two and five digits and that are not in the cookie or referrer header. I right click on the first value and select "find selection in responses". Then I right click on the first highlighted response and click "create extractor". The hexadecimal value that we need to extract from this response is already highlighted. Another thing we learned from testing NAV is that the dynamic values can appear either in plain HTML as an ID of a div tag or in a JSON string. In this request, the value is in the HTML div tag. I will create a regular expression extractor. I paste a template of the regular expression that searches for an ID of a div tag and substitute the class name with the div element we need. Then verify that the return value of the extractor is correct. Give the extractor a meaningful name and save it. Back in the dynamic values view, we need to substitute the dynamic value with the extractor we just created. Right-click on it and select "replace selection with parameter". The "Create Parameter" window opens. Right-click on the value, and from the variable picker tree, select the extractor that we just created. This parameter is complete. Since the value we parameterized may be used in requests several times, we want to make sure that all its occurrences are replaced with this parameter. Right click and choose "Create more like this". In the find and replace dialog, the fields will be prefilled, so just click bulk replace. Eighteen more parameters were created. They also appear in the test case tree. We have finished parameterizing the first dynamic value. Let's move on to the second one. Right click and find the response that contains it. Let's create an extractor from this response, like we did before. This time, the dynamic value appears in JSON. It is surrounded by HTML. Let's first extract the JSON string from HTML, and then create the second extractor from the first one using JPATH query. This first extractor will be text delimited. The JSON string is used as a JavaScript function parameter. I highlight the text before the function's open parenthesis, as well as the open bracket, and set it as "Text Before". The "Text After" is simply a closing bracket and parenthesis, as well as a semicolon. Let's verify the extractor to make sure only JSON is extracted. Let's give it a name, then save and close. Now from the extractor we just created, I will create a second extractor. Let's select the value to extract and click "Create JPATH query" on the toolbar. The JPATH query is created automatically and it works correctly. Let's give it a name and save. Now we need to replace the value with a parameter, like we did before. I select the extractor that we just created. Then we'll try to create more similar parameters. No more occurrences of the dynamic value were found. We parameterized all relevant dynamic values in request 19. Now let's run "Verify" again to see if any warnings were fixed. As you can see, we have one less warning, and response 19 is now good. To fix the rest of the warnings, we just repeat the same steps until all of them are resolved. I will demonstrate the process for one more response. This time the dynamic value is found in pure JSON, so we will simply create a JPATH extractor. Now I will create a parameter. Let's run verify again and as you can see, another warning is resolved. I will continue this process of resolving the correlation warnings one-by-one. Let's fast forward. After correlating the last dynamic value, I run Verify again and now all warnings are resolved. To double check that this test case is fully correlated I will make sure that the test run creates new invoices. Before running the test I will check the last invoice number in NAV. It is 1179. Now I will run a test with one user and two iterations. Two more invoices should be created. Test completed. Back in NAV: now there are two more invoices that weren't here before. Now that we know this script works, we can run load tests and analyze performance. With this approach you can record, correlate and load test any scenario in Dynamics NAV without writing a single line of script. Thank you for watching.