Run the reset contract over every indicator, not only the tested ones - #9729
Open
mkzung wants to merge 1 commit into
Open
Run the reset contract over every indicator, not only the tested ones#9729mkzung wants to merge 1 commit into
mkzung wants to merge 1 commit into
Conversation
CommonIndicatorTests states eleven contracts and runs them for the 115 indicators that have a test class deriving from it. The other 87 concrete indicators in the assembly are never asked. This fixture drives every one of them by reflection. It feeds a series, resets, feeds the same series again, and asserts the values and the ready flag match, then asserts the indicator is back in its default state using TestHelper.AssertIndicatorIsInDefaultState. Three periods rather than one, because a field can be assigned on a branch only one period takes: a value written on the early return an indicator makes while a sub-indicator warms up is overwritten on the first update whenever that warm-up lasts more than one bar. The series length follows the warm-up period, so an indicator with a long one is compared over values it produced while ready rather than only over its pre-ready value. A type the fixture cannot construct, cannot feed, or that throws on the series is reported with Assert.Ignore and the reason, so the runner counts it and names it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Tests/Indicators/IndicatorResetContractTests.cs, one new file. It constructs every indicator in the assembly by reflection, at three periods, and asserts two things: the same series replayed around aReset()gives the same values and the same ready flag, and the indicator is back in its default state afterwards, usingTestHelper.AssertIndicatorIsInDefaultState.Related Issue
Closes #9726
Motivation and Context
CommonIndicatorTests<T>states eleven contracts and runs them only for an indicator with a test class deriving from it: 115 of the 202 concrete indicators. Six reset defects were merged this month out of that gap.The case for it is not a bug count, since it is green on master. It is what happens when the six merged fixes are reverted, keeping the fixture:
IsReadydiffers at index 1, across the four indicators sharing the baseIsReadytrue after the resetThree notes on the shape, since each was a choice:
Three periods, because of #9688.
SuperTrendassigned its previous close on the early return it takes while the average true range warms up, so at any period above one that return fires on the first update and the stale value never shows.The price series never revisits a level. A repeating one caught two of the six, because a value carried across a reset is one the indicator meets again a few bars later anyway.
Anything unreachable is an
Assert.Ignorecarrying its reason, so the runner counts it and names it rather than passing over it. On master that is 70 cases over 18 indicators: 36 the fixture cannot construct, 18 that throw on the series, 16 where a constructor refuses that period and the ignore quotes the indicator's own message.Two of the five that throw are worth a look on their own:
AutoRegressiveIntegratedMovingAverageis #9714, andChoppinessIndexat a period of one is #9724.Requires Documentation Change
No.
How Has This Been Tested?
on
b0006b29a, plus the reverted-fix run above. The neighbouring fixtures are unaffected:IndicatorTests,ChoppinessIndexTests,MidPriceTests,SuperTrendTests,IntradayVwapTests,ConnorsRelativeStrengthIndexTests,AdvanceDeclineDifferenceTestsandNewHighsNewLowstogether give 0 failed.Types of changes
Checklist:
bug-<issue#>-<description>orfeature-<issue#>-<description>