Web-Integration Test: Screen 'login' is not defined. Make sure the screen controller is located inside or below the base package specified in <gui:screens> element of web-spring.xml

I’m trying to write web-integration tests on my login screen. The login screen is extended in a base module that I install through gradle in the actual application.

dependencies {
     appComponent("com.haulmont.cuba:cuba-global:$cubaVersion")
    appComponent('dental.gc.base:gc-base-global:0.1-SNAPSHOT')
}

I also istall it as a test dependency (at least I think I do)

configure([globalModule, coreModule, webModule]) {
    apply(plugin: 'java')
    apply(plugin: 'maven')
    apply(plugin: 'cuba')

   dependencies {
        testCompile('org.junit.jupiter:junit-jupiter-api:5.5.2')
        testCompile('org.junit.jupiter:junit-jupiter-engine:5.5.2')
        testCompile('org.junit.vintage:junit-vintage-engine:5.5.2')
        testCompile('dental.gc.base:gc-base-global:0.1-SNAPSHOT')    
    }
...

The application as such works fine, but tests fails when trying to load the AppLoginScreen screen:

Screen 'login' is not defined. Make sure the screen controller is located inside or below the base package specified in <gui:screens> element of web-spring.xml

so I tried in my web-spring.xml to include it as adviced:

    <!-- Annotation-based beans -->
    <context:component-scan base-package="dental.gc.userlifecyclemgmt"/>
    <gui:screens base-packages="dental.gc.base.web"/>
    <gui:screens base-packages="dental.gc.userlifecyclemgmt.web"/>

That doesn’t make a difference though.

Looks like I just found the solution

    @RegisterExtension
    TestUiEnvironment environment = new 
     TestUiEnvironment(UserlifecyclemgmtWebTestContainer.Common.INSTANCE)
        .withScreenPackages(
                "com.haulmont.cuba.web.app.main",
                "dental.gc.userlifecyclemgmt.web.screens",
                "dental.gc.base.web.screens", // adding this made the screen available
                "dental.gc.userlifecyclemgmt.web.screens.hruser")
        .withUserLogin("admin");

Although now I got a duplicate screen

Project contains screens with the same id: 'extMainScreen'. See 'dental.gc.base.web.screens.ExtMainScreen' and 'dental.gc.userlifecyclemgmt.web.screens.ExtMainScreen'

Hello!

Yes, you should add the screen package to the TestUiEnvironment where to scan screens annotated by @UiController annotation.
The exception occurs because the add-on you added has an extended main screen with the same id extMainScreen as the extended main screen in your application. You can change the id of the extended main screen in the add-on or in the application.

Thank you, yes that’s exactly what I did.