eclipse-archived / smarthome

Eclipse SmartHome™ project
https://www.eclipse.org/smarthome/
Eclipse Public License 2.0
861 stars 784 forks source link

[test failures] ChannelItemProviderTest.testDisableBeforeDelayedInitialization #5720

Open sjsf opened 6 years ago

sjsf commented 6 years ago

From https://ci.eclipse.org/smarthome/job/SmartHomeDistribution-Nightly-PR/433:

Running org.eclipse.smarthome.core.thing.internal.ChannelItemProviderTest
Tests run: 5, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.393 sec <<< FAILURE! - in org.eclipse.smarthome.core.thing.internal.ChannelItemProviderTest
testItemCreation_notThere(org.eclipse.smarthome.core.thing.internal.ChannelItemProviderTest)  Time elapsed: 0.287 sec
testItemRemoval_linkRemoved(org.eclipse.smarthome.core.thing.internal.ChannelItemProviderTest)  Time elapsed: 0.004 sec
testItemRemoval_itemFromOtherProvider(org.eclipse.smarthome.core.thing.internal.ChannelItemProviderTest)  Time elapsed: 0.002 sec
testItemCreation_alreadyExists(org.eclipse.smarthome.core.thing.internal.ChannelItemProviderTest)  Time elapsed: 0.001 sec
testDisableBeforeDelayedInitialization(org.eclipse.smarthome.core.thing.internal.ChannelItemProviderTest)  Time elapsed: 0.096 sec  <<< FAILURE!
org.mockito.exceptions.verification.NeverWantedButInvoked: 
listener.added(
    same(org.eclipse.smarthome.core.thing.internal.ChannelItemProvider@46051269),
    same(test (Type=NumberItem, State=NULL, Label=null, Category=null))
);
Never wanted here:
-> at org.eclipse.smarthome.core.thing.internal.ChannelItemProviderTest.testDisableBeforeDelayedInitialization(ChannelItemProviderTest.java:140)
But invoked here:
-> at org.eclipse.smarthome.core.thing.internal.ChannelItemProvider.createItemForLink(ChannelItemProvider.java:288)

    at org.eclipse.smarthome.core.thing.internal.ChannelItemProviderTest.testDisableBeforeDelayedInitialization(ChannelItemProviderTest.java:140)
sjsf commented 6 years ago

@velichkos as you implemented that test case - do you immediately have an idea what might have gone wrong here?

velichkos commented 6 years ago

It looks like a timing issue: the component has a delayed initialization feature and the test asserts that the listeners will return without doing anything before the delayed initialization has passed. It is possible that in this execution the delayed initialization already completed before the test called the listener here: provider.linkRegistryListener.added(new ItemChannelLink(ITEM_NAME, CHANNEL_UID));