Skip to content
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

Repeat mode for integration tests #1911

Merged
merged 3 commits into from
Jul 16, 2024
Merged

Repeat mode for integration tests #1911

merged 3 commits into from
Jul 16, 2024

Conversation

odisseus
Copy link
Contributor

@odisseus odisseus commented Jul 15, 2024

To use it, add the option -PrepeatTests to the command line. Example:

./gradlew integrationTest -PrepeatTests=20

Test plan

  1. Introduce non-deterministic failures, like this:
    val x = Random.nextInt() % 10
    if (x < 2) {
        fail()
    } else if (x < 4) {
        1 / 0
    } else if (x < 6) {
        throw IllegalStateException("$x")
    }
  2. Run the tests with high enough repetition count
  3. Verify that different stack traces are present in the test report
Screenshot 2024-07-16 at 11 17 46

@odisseus odisseus self-assigned this Jul 15, 2024
@@ -508,6 +508,7 @@ tasks {
description = "Runs the integration tests."
sharedIntegrationTestConfig(buildCodyDir, "replay")
dependsOn("processIntegrationTestResources")
project.properties["repeatTests"]?.let { systemProperty("repeatTests", it) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you need it to be a system property you don't need to do that, but instead you can run gradle with -DrepeatTests instead of -PrepeatTests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Stackoverflow, the -D argument won't necessarily pass through to the tests.

import org.junit.runners.BlockJUnit4ClassRunner
import org.junit.runners.model.FrameworkMethod

class CustomJunitClassRunner(klass: Class<*>?) : BlockJUnit4ClassRunner(klass) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also something with Repeatable or Repeat in name? Custom doesn't bring too much context

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class doesn't really repeat anything or make anything repeatable. I don't mind renaming it, but I can't think of any good name.

@pkukielka
Copy link
Contributor

Could you somehow attach example off test report or at least screenshot of it?

Copy link
Contributor

@mkondratek mkondratek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it easily doable to replace

DocumentCodeTest. testGetsFoldingRanges
DocumentCodeTest. testGetsFoldingRanges
DocumentCodeTest. testGetsFoldingRanges
...

with

DocumentCodeTest. testGetsFoldingRanges (0)
DocumentCodeTest. testGetsFoldingRanges (1)
DocumentCodeTest. testGetsFoldingRanges (2)
...

@odisseus
Copy link
Contributor Author

Not without writing a lot more code. I will try to do that in a follow-up PR.

@odisseus odisseus merged commit b308166 into main Jul 16, 2024
7 checks passed
@odisseus odisseus deleted the mg/cody-2828 branch July 16, 2024 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants