You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You restored original mocking semantics when an expectation is recorded on a mocked base class: #236
It was not restored for mocked abstract base class.
Abstract base class works with @capturing and partial mocking. @mocked doesn't work.
publicfinalclassTestSubClass {
publicstaticabstractclassBaseClass {
Stringname;
publicStringgetName() {
returnname;
}
publicvoidsetName(Stringn) {
name = n;
}
}
finalstaticclassSubClassextendsBaseClass {
}
/** * with jomckit version 1.20+ : * -fails if @Mocked used on abstract base class * -works if @Mocked used on non-abstract base class * * with jmockit version 1.19 : * -this test works * * @param baseClass */@TestpublicvoidtestGetName_fails(final@MockedBaseClassbaseClass) {
newExpectations() {
{
baseClass.getName();
result = "mocked name";
}
};
assertEquals("mocked name", newSubClass().getName());
}
/** * works with abstract and non-abstract base class * @param baseClass */@TestpublicvoidtestGetName_works(final@CapturingBaseClassbaseClass) {
newExpectations() {
{
baseClass.getName();
result = "mocked name";
}
};
assertEquals("mocked name", newSubClass().getName());
}
/** * partial mocking works with abstract and non-abstract base class * @param baseClass */@TestpublicvoidtestGetName_works2() {
finalSubClasssubClass = newSubClass();
newExpectations(subClass) {
{
subClass.getName();
result = "mocked name";
}
};
assertEquals("mocked name", subClass.getName());
}
}
The text was updated successfully, but these errors were encountered:
Jmockit Version 1.20+
You restored original mocking semantics when an expectation is recorded on a mocked base class:
#236
It was not restored for mocked abstract base class.
Abstract base class works with @capturing and partial mocking. @mocked doesn't work.
The text was updated successfully, but these errors were encountered: