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

Setting up @Tested object in a @BeforeMethod #461

marek-krajewski opened this issue Sep 20, 2017 · 0 comments

Setting up @Tested object in a @BeforeMethod #461

marek-krajewski opened this issue Sep 20, 2017 · 0 comments


Copy link

@marek-krajewski marek-krajewski commented Sep 20, 2017

Please provide the following information:

  • Version of JMockit that was used:
    JMockit 1.34
    TestNG 6.12
  • Description of the problem:

It seems that the availableDuringSetup parameter of the @Tested annotation constructs the annotated object only once for all unit tests in the class. Hopefully this example will show quickly what I mean:

class TestedClass {
    int addCount = 1;

    public void add() {

public class Test {

    @Tested(availableDuringSetup = true)
    TestedClass testedClass;

    public void setup() {

    public void test_1() {testedClass.add(); }
    public void test_2() {testedClass.add(); }

Output for availableDuringSetup = true : 1 2
Output for availableDuringSetup = false: 1 1

Is that intentional? And if so, then is there some other way to force the reconstruction of the @Tested object before each execution of the @BeforeMethod?

@rliesenfeld rliesenfeld self-assigned this Sep 20, 2017
@jmockit jmockit locked and limited conversation to collaborators Oct 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

No branches or pull requests

2 participants