Skip to content

Cascading issue? #98

@ihoro

Description

@ihoro

I cannot tell what exactly is a problem here, but in the following example a() and b() are passed but c() fails. If you remove "extends Serializable" then all of them will be passed.
Windows7 x64, OracleJDK 1.8.0_25, TestNG 6.8.8, JMockit 1.13
Any idea what it can be?

package mockit;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.io.Serializable;
import static org.testng.Assert.assertNull;

class Parent<T extends Serializable> {
  private T id;
  public T getId() { return id; }
}
class Foo extends Parent<Long> {}
class Bar extends Parent<Long> {}
interface FooService { Foo getFoo(); }
interface BarService { Bar getBar(); }

public class CascadingTest {
  @Mocked FooService fooService;
  @Mocked BarService barService;

  @BeforeMethod void beforeMethod() {
    new NonStrictExpectations() {{
      barService.getBar();
    }};
  }

  @Test public void a() {
    assertNull(new Foo().getId());
  }

  @Test public void b() {
    new NonStrictExpectations() {{
      fooService.getFoo();
    }};
    assertNull(new Foo().getId());
  }

  @Test public void c() {
    assertNull(new Foo().getId());
  }
}
java.lang.AssertionError: expected [null] but found [java.lang.Long@19b02dfd]
        at mockit.CascadingTest.c(CascadingTest.java:38)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions