Skip to content

Try another approach to mark hanging generated tests #371 #554

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

Conversation

Vassiliy-Kudryashov
Copy link
Member

@Vassiliy-Kudryashov Vassiliy-Kudryashov commented Jul 19, 2022

Description

Note, this issue affects JUnit 5 only!

New methods and entities were added to codegen to provide required assertion wrapper. Now tests with timeout are being abrupt just after exceeding time limit.

Fixes #371

Type of Change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Manual Scenario

Set handing test timeout to 100ms and generate tests for the example:

package issue371;

import java.io.File;

public class PomXmlFinder {
    public static void main(String[] args) {
        scan(new File("C:\\"));
    }

    private static int counter = 0;

    private static void scan(File file) {
        if (counter > 10) return;
        if (file.isFile() && file.getName().equals("pom.xml")) {
            counter++;
            if (counter > 10) return;
            System.out.println(file.getAbsolutePath());
        }
        File[] files = file.listFiles();
        if (files != null) {
            for (File child : files) {
                scan(child);
            }
        }
    }
}

Generated test methods should be not only annotated with @Timeout tag but also have wrappers like assertTimeoutPreemptively(Duration.ofMillis(100L), () -> PomXmlFinder.main(stringArray)); inside

Checklist (remove irrelevant options):

  • The change followed the style guidelines of the UTBot project
  • Self-review of the code is passed
  • No new warnings

@Vassiliy-Kudryashov Vassiliy-Kudryashov linked an issue Jul 19, 2022 that may be closed by this pull request
@Vassiliy-Kudryashov Vassiliy-Kudryashov enabled auto-merge (squash) July 19, 2022 14:20
@Vassiliy-Kudryashov Vassiliy-Kudryashov merged commit 2fc63ac into main Jul 19, 2022
@Vassiliy-Kudryashov Vassiliy-Kudryashov deleted the Vassiliy-Kudryashov/371-try-another-approach-to-mark-hanging-generated-tests branch July 19, 2022 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Try another approach to mark hanging generated tests
2 participants