Skip to content

Bad static method mocking #1128

Closed
Closed
@SBOne-Kenobi

Description

@SBOne-Kenobi

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.

Metadata

Metadata

Assignees

Labels

ctg-bugIssue is a bug

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions