GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Bad static method mocking · Issue #1128 · UnitTestBot/UTBotJava

Bad static method mocking #1128

New issue
Copy link
New issue
Copy link
Closed
#1142
Closed
Bad static method mocking#1128
#1142
Copy link
Assignees
SBOne-Kenobi
Labels
ctg-bugIssue is a bugIssue is a bug

Description

@SBOne-Kenobi
SBOne-Kenobi
opened on Oct 10, 2022
Issue body actions

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.

Activity

  1. SBOne-Kenobi
    added
    ctg-bugIssue is a bugIssue is a bug
    on Oct 10, 2022
  2. SBOne-Kenobi
    self-assigned this
    on Oct 10, 2022
  3. korifey
    added this to UTBot Javaon Oct 10, 2022
  4. korifey
    moved this to Todo in UTBot Javaon Oct 10, 2022
  5. SBOne-Kenobi
    closed this as completedin #1142on Oct 12, 2022
  6. Repository owner moved this from Todo to Done in UTBot Javaon Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @SBOne-Kenobi
    SBOne-Kenobi

Labels

ctg-bugIssue is a bugIssue is a bug

Type

No type

Projects

  • UTBot Java
    Status
    Done
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.