Skip to content

Enum value corrupted after recording expectations in 1.13 #94

@b2064832

Description

@b2064832

JMockit 1.13 corrupts enum values after recording expectations. Version 1.12 is working.
Failing test:

import mockit.Mocked;
import mockit.NonStrictExpectations;
import org.testng.annotations.Test;

import static org.testng.Assert.assertEquals;

public class JMockitEnumTest {
public static enum MyEnum {
FOO("foo");
private final String value;

    private MyEnum(final String value) {
        this.value = value;
    }

    public String getValue() {
        return value;
    }
}

public static interface Mockable {
    MyEnum getMyEnum();
}

@Test
public void test(@Mocked final Mockable mockable) throws Exception {
    assertEquals(MyEnum.FOO.getValue(), "foo");
    new NonStrictExpectations() {{ //or Expectations
        mockable.getMyEnum();
        result = MyEnum.FOO;
    }};
    assertEquals(MyEnum.FOO.getValue(), "foo", "Enum value corrupted after mocking."); // fails here, value null
}

}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions