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

Bad static method mocking #1128

Closed
SBOne-Kenobi opened this issue Oct 10, 2022 · 0 comments · Fixed by #1142
Closed

Bad static method mocking #1128

SBOne-Kenobi opened this issue Oct 10, 2022 · 0 comments · Fixed by #1142
Assignees
Labels
ctg-bug Issue is a bug

Comments

@SBOne-Kenobi
Copy link
Collaborator

SBOne-Kenobi commented Oct 10, 2022

Description

Concrete Executor wrongly mocks static methods from different classes but with same signatures.

To Reproduce

Steps to reproduce the behavior:

public class AlsoRandom {
    public static int next() {
        return -42;
    }

    public static int foo() {
        return 1;
    }
}

public class Random {
    public static int next() {
        return 42;
    }

    public static int foo() {
        return 0;
    }
}


public class RandomUsage {
    public static int usage() {
        int value = Random.next();
        int a = Random.foo();
        int b = AlsoRandom.foo();
        if (value > 50) {
            return a + b;
        }

        return AlsoRandom.next() - value;
    }
}
  1. Write some classes described above in new java project in IntelliJ Idea
  2. Use plugin to generate tests
  3. Run the generated test

Expected behavior

Tests are passed.

Actual behavior

Tests are failed.

Environment

Mocking static methods from another class.

@SBOne-Kenobi SBOne-Kenobi added the ctg-bug Issue is a bug label Oct 10, 2022
@SBOne-Kenobi SBOne-Kenobi self-assigned this Oct 10, 2022
@korifey korifey moved this to Todo in UTBot Java Oct 10, 2022
@SBOne-Kenobi SBOne-Kenobi mentioned this issue Oct 12, 2022
7 tasks
Repository owner moved this from Todo to Done in UTBot Java Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ctg-bug Issue is a bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant