-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed url paths not covered in api coverage report #687
Conversation
…pected url when the path had multiple path parameters due to regex pattern matching error during parsing
@@ -6,7 +6,7 @@ import `in`.specmatic.core.Result | |||
|
|||
class ScenarioTestGenerationFailure(val scenario: Scenario, val e: Throwable) : ContractTest { | |||
override fun testResultRecord(result: Result): TestResultRecord { | |||
return TestResultRecord(scenario.path.replace(Regex("""\((.*):.*\)"""), "{$1}"), scenario.method, scenario.httpResponsePattern.status, result.testResult()) | |||
return TestResultRecord(scenario.path.replace(Regex("""\((.*?):.*?\)"""), "{$1}"), scenario.method, scenario.httpResponsePattern.status, result.testResult()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a unit test for this method
@@ -6,7 +6,7 @@ import `in`.specmatic.core.executeTest | |||
|
|||
class ScenarioTest(val scenario: Scenario, private val generativeTestingEnabled: Boolean = false) : ContractTest { | |||
override fun testResultRecord(result: Result): TestResultRecord { | |||
return TestResultRecord(scenario.path.replace(Regex("""\((.*):.*\)"""), "{$1}"), scenario.method, scenario.status, result.testResult()) | |||
return TestResultRecord(scenario.path.replace(Regex("""\((.*?):.*?\)"""), "{$1}"), scenario.method, scenario.status, result.testResult()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a unit test for this method
@@ -110,7 +110,7 @@ class TestReport(private val testReportRecords: MutableList<TestResultRecord> = | |||
logger.newLine() | |||
|
|||
val recordsWithFixedURLs = testReportRecords.map { | |||
it.copy(path = it.path.replace(Regex("""\((.*):.*\)"""), "{$1}")) | |||
it.copy(path = it.path.replace(Regex("""\((.*?):.*?\)"""), "{$1}")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you extract this functionality to a method and add a unit test.
The functionality of doing the regex replace across all 3 seems the same.. if so, can you extract the regex replace itself into a common method.
…on brackets to braces to its own function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks @vikram-rao!
What: Url path with multiple path parameters is not parsed correctly due to regex pattern matching error during parsing (requires non-greedy matching)
Why: Api Coverage is incorrect due to wrong path string manipulation. All apis with multiple path params are marked as not covered
How: Simple modification of the regex used for path conversion to be non greedy using
?
operatorChecklist:
Issue ID:
N/A