I tried to write a simple integration test following the page UI Integration Tests :: Jmix Documentation
However, I get a ClassCastException when ClaimListView claimListView = UiTestUtils.getCurrentView();
is called.
I checked that I don’t have any duplicate classes. I tried to run the test in IntelliJ and from Gradle (also ran clean
before ‘test’) with the same result. I’m using JMIX 2.5.2. The code runs fine when I text the app in the browser.
Do you have any ideas why I get the exception?
Exception:
class com.company.jmix.recoveryplan.view.claim.claim.ClaimListView cannot be cast to class com.company.jmix.recoveryplan.view.claim.claim.ClaimListView (com.company.jmix.recoveryplan.view.claim.claim.ClaimListView is in unnamed module of loader io.jmix.core.impl.JavaClassLoader$FileClassLoader @23b2eda9; com.company.jmix.recoveryplan.view.claim.claim.ClaimListView is in unnamed module of loader 'app')
java.lang.ClassCastException: class com.company.jmix.recoveryplan.view.claim.claim.ClaimListView cannot be cast to class com.company.jmix.recoveryplan.view.claim.claim.ClaimListView (com.company.jmix.recoveryplan.view.claim.claim.ClaimListView is in unnamed module of loader io.jmix.core.impl.JavaClassLoader$FileClassLoader @23b2eda9; com.company.jmix.recoveryplan.view.claim.claim.ClaimListView is in unnamed module of loader 'app')
at com.company.jmix.recoveryplan.view.claim.claim.ClaimWithRecoveryPlanViewTest.givenClaimListView_whenOpenClaimWithRecoveryPlanWithBalanceZero_thenRecoveryStepEditingDisabled(ClaimWithRecoveryPlanViewTest.java:36)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
This is the relevant part of the test:
@UiTest
@SpringBootTest(classes = {RecoveryplanApplication.class, FlowuiTestAssistConfiguration.class})
public class ClaimWithRecoveryPlanViewTest {
@Autowired
ViewNavigators viewNavigators;
@Test
void givenClaimListView_whenOpenClaimWithRecoveryPlanWithBalanceZero_thenRecoveryStepEditingDisabled() {
// Navigate to user claim view
viewNavigators.view(UiTestUtils.getCurrentView(), ClaimListView.class).navigate();
ClaimListView claimListView = UiTestUtils.getCurrentView();
}
}