Fix Random thread safety and control random seed to improve testability #4361
Labels
Area: Adaptive expression
The issue is related to Adaptive expressions
Area: Adaptive
The issue is related to Adaptive dialogs
Problem
Our usage of Random is not thread safe and when writing tests, you currently need to test for all random responses. This makes it harder to write tests and adds minimally to the test coverage. One method in particular is to take a transcript and turn it into declarative test to make sure the same path gets executed. This does not work if there is any variation in .lg templates or if the random selector is used.
Context
Where random is used:
Solution
To support recording a transcript with the random value set we also need to add this to the emulator which will allow emitting the test event while specifying the RandomValue. microsoft/BotFramework-Emulator#2174
With these in place a transcript will contain the Microsoft.SetTraceOptions trace that can be included in a declarative test to emit the same activity so that the test script will have the same predictable behavior.
This solution will enable us to control the random choices made so that we can ensure that a test will run consistently. Once we have made these improvements, we will also need to add the middle ware to the default Composer runtime.
[enhancement]
The text was updated successfully, but these errors were encountered: