The strategy unit test case is failing

I am trying to create a test case for a strategy however when I try to run the test case with a data transform for some reason the data transform is not getting called and the test is failing. I’ve tried to trace it and I could not find anything that could help me.

When I tested the strategy via the test panel with the same data transform used in the test case I am getting results so it should work when I do the test case as well.

Any ideas or guidance of how I can make my test case passing will be appreciated.

@SilviuStefan

If this RS is valid to take the DT . then other options might be :

  1. If the Strategy rule that you are testing uses external input from another Strategy rule, perform the following actions:

    1. In the For external inputs use strategy field, enter the name of the Strategy rule that generates the input.

    2. Optional: To obtain the input directly from the component that generates it, select the Specify a single component within the strategy check box and then select the component.

      If you do not specify a component, the application obtains the input from the results component of the Strategy rule that generates the input.

  2. Run the test by performing one of the following actions:

    • On a checked-out Strategy rule, click Save and Run.
    • On a checked-in Strategy rule, click Run.

@SilviuStefanThank you for your post.

The following steps will help you.

  • Open the Strategy to be tested

  • Configure the test setup with the Data Transform in the Strategy canvas Test Panel

  • Run the strategy

  • When the test completes, click “Convert to test”

This will generate a test case for the strategy with the correct Setup step.

Note I recommend the following:

  • Pay attention to the strategy component currently hightlighted on the strategy canvas when you press convert to test. On the Test Case it will evaluate that component.

  • In the Setup activity, remove the PrimaryPageJson parameter value to ensure the data transform is always evaluated.

In the event you want to test a strategy that relies on external input StrategyResult data, I recommend creating a wrapper strategy and creating the test on that wrapper strategy.