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

IllegalStateException if using inner test-classes and ValueProviderExtension been declared on top-level #40

Open
yobinx opened this issue Oct 23, 2024 · 1 comment

Comments

@yobinx
Copy link

yobinx commented Oct 23, 2024

Having inner classes inside the test and the ValueProviderExtension is been declared on the top-level class, e.g.:

@ExtendWith(ValueProviderExtension.class)
class MyTestClass {

    @Nested
    class MyInnerTestClass1 {
        @Test
        void test() {
        }
    }

    @Nested
    class MyInnerTestClass2 {
        @Test
        void test() {
        }
    }
}

Then the following exception is been thrown:

java.lang.IllegalStateException: Illegal transition, cannot switch from DEFAULT back to TEST_CLASS
	at com.google.common.base.Preconditions.checkState(Preconditions.java:836)
	at com.tngtech.valueprovider.ValueProviderFactory.checkMayFinish(ValueProviderFactory.java:90)
	at com.tngtech.valueprovider.ValueProviderFactory.doFinishTestClassCycle(ValueProviderFactory.java:62)
	at com.tngtech.valueprovider.ValueProviderFactory.finishTestClassCycle(ValueProviderFactory.java:152)
	at com.tngtech.valueprovider.ValueProviderExtension.finishTestClassCycle(ValueProviderExtension.java:115)
	at com.tngtech.valueprovider.ValueProviderExtension.afterAll(ValueProviderExtension.java:99)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
@jonashoef
Copy link
Contributor

Thank you for bringing this deficiency up, @yobinx, and please forgive me for my late response.
According to my first, admittedly rough analysis, adding support for @Nested inner test classes should be possible.
I will get back to you as soon as I have a working solution.

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