You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When evaluating code coverage for files containing Kotlin inline functions, the coverage report inaccurately displays the coverage status. Inline functions may appear as either uninstrumented (highlighted in grey) or not covered (highlighted in red) despite being hit by test cases.
/** * Consumes the next [Token] (which is assumed to be type [T], otherwise the error provided by * [missingError] is used) and returns the result.*/inlinefun <reifiedT : Token> consumeTokenOfType(
missingError: () ->MathParsingError = { GenericError }
): MathParsingResult<T> {
println("In consume Token of type")
val maybeToken = tokens.expectNextMatches { it isT } as?Treturn maybeToken?.let { token ->println("Hit in maybe Token")
previousToken = token
MathParsingResult.Success(token)
} ?: missingError().toFailure()
}
Debug lines are added to assist with verifying coverage.
Run Tests:
Execute tests on MathExpressionParserTest.kt to confirm that the inline function is hit by the test cases:
Running:
bazel test utility/src/test/java/org/oppia/android/util/math:MathExpressionParserTest --test_filter=testParseNumExp_largeRealExponent_optionalErrorsDisabled_doesNotFail
Logged:
INFO: From Testing //utility/src/test/java/org/oppia/android/util/math:MathExpressionParserTest:
==================== Test output for //utility/src/test/java/org/oppia/android/util/math:MathExpressionParserTest:
JUnit4 Test Runner
.In consumer Token of type
Hit in may be Token
In consumer Token of type
Hit in may be Token
In consumer Token of type
Hit in may be Token
Time: 0.086
OK (1 test)
Run code coverage analysis on MathExpressionParser.kt,
bazel run //scripts:run_coverage -- $(pwd) utility/src/main/java/org/oppia/android/util/math/MathExpressionParser.kt
Check Coverage Report:
Review the generated HTML code coverage report for MathExpressionParser.kt.
Despite the function being executed during tests, the lines are incorrectly reported as not covered.
Raw coverage info:
To analyze the raw coverage data, run the following bazel coverage command:
Describe the bug
When evaluating code coverage for files containing Kotlin inline functions, the coverage report inaccurately displays the coverage status. Inline functions may appear as either uninstrumented (highlighted in grey) or not covered (highlighted in red) despite being hit by test cases.
Steps To Reproduce
Examine MathExpressionParser.kt, which contains the following inline function:
Debug lines are added to assist with verifying coverage.
Execute tests on MathExpressionParserTest.kt to confirm that the inline function is hit by the test cases:
Running:
bazel test utility/src/test/java/org/oppia/android/util/math:MathExpressionParserTest --test_filter=testParseNumExp_largeRealExponent_optionalErrorsDisabled_doesNotFail
Logged:
MathExpressionParser.kt
,bazel run //scripts:run_coverage -- $(pwd) utility/src/main/java/org/oppia/android/util/math/MathExpressionParser.kt
Review the generated HTML code coverage report for
MathExpressionParser.kt
.Despite the function being executed during tests, the lines are incorrectly reported as not covered.
Raw coverage info:
To analyze the raw coverage data, run the following bazel coverage command:
coverage.dat info for the inline function lines:
Expected Behavior
The coverage report should highlight the lines in green, indicating that they are covered by the tests.
Additional Context
Most inline functions are marked as uninstrumented in the coverage report.
BundleExtensions.kt
Bazel version
6.5.0
rules_kotlin
v1.7.1
sha: fd92a98bd8a8f0e1cdcb490b93f5acef1f1727ed992571232d33de42395ca9b3
What device/emulator are you using?
No response
Which Android version is your device/emulator running?
No response
Which version of the Oppia Android app are you using?
No response
The text was updated successfully, but these errors were encountered: