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

LockAssert.TestHelper.makeAllAssertsPass(false) throws NoSuchElementException #1635

Closed
sebastianjkl opened this issue Dec 6, 2023 · 3 comments

Comments

@sebastianjkl
Copy link

Hi,

since 5.7.0 calling LockAssert.TestHelper.makeAllAssertsPass(false) throws NoSuchElementException.

java.util.NoSuchElementException
	at java.base/java.util.LinkedList.removeLast(LinkedList.java:287)
	at net.javacrumbs.shedlock.core.LockAssert.endLock(LockAssert.java:46)
	at net.javacrumbs.shedlock.core.LockAssert$TestHelper.makeAllAssertsPass(LockAssert.java:81)

Full example (tested with latest 5.10.0):

private final UnitUnderTest unitUnderTest = new UnitUnderTest();

@Test
void shouldThrowIllegalStateExceptionTheTaskIsNotLocked() {
    LockAssert.TestHelper.makeAllAssertsPass(false);

    final Throwable throwable = catchThrowable(unitUnderTest::run);

    then(throwable).isInstanceOf(IllegalStateException.class).hasMessage("The task is not locked.");
}

@Slf4j
static class UnitUnderTest {

    public void run() {
        LockAssert.assertLocked();
        log.info("Do something...");
    }

}

With 5.6.0 and before the test was not failing.

Should calling LockAssert.TestHelper.makeAllAssertsPass(false); work regardless if there is an active lock or not?

@lukas-krecan
Copy link
Owner

Thanks, I will look at it in next few days

@lukas-krecan
Copy link
Owner

Fixed in 5.10.1, thanks for reporting

@sebastianjkl
Copy link
Author

Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants