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

Mocking call chain does not work for public interface hierarchy in multiple tests #420

Milbor-zz opened this issue May 29, 2017 · 0 comments


Copy link

@Milbor-zz Milbor-zz commented May 29, 2017

testng 6.9.10

when whole test class run - test1 passes, test2 fails with NPE when mocking call chain.
Passes in 1.31.
Is this bug? I don't see anything relevant in release notes.
Please see comments in code. Interface and class public visibility affects test result.

public class SpikeTest {
    private SubInterface subInterface;

    public void test1() {

    public void test2() {

    private void test() {
        final String expected = "mocked";
        new Expectations() {{
            result = expected;
        final String actual = subInterface.getData().get();
        assertSame(actual, expected);

    interface ParentInterface {
        Data getData();

    // both tests pass with default visibility
    public interface SubInterface extends ParentInterface {

    // first test fails with default visibility
    // java.lang.IllegalAccessError: tried to access class SpikeTest$Data from class $Impl_SubInterface
    public static class Data {
        String get() {
            throw new UnsupportedOperationException();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

No branches or pull requests

2 participants