Testing ?

Hi
What would you recommend for integration testing with CUBA ?
As most of code is hidden in xml files or framework classes, it is difficult to envision which framework would fit to do automated tests using the UI.
Thanks
Mike

2 Likes

Hi,

you can use Selenium to test CUBA applications and to simplify this task I recommend you to enable special test mode.

In your web-app.properties file you have to set:


cuba.testMode = true

In this mode each CUBA ui component will set its id to the cuba-id attribute of a corresponding DOM element.

I strongly recommend you to use Selenide library to deal with asynchronous UI changes because all the requests from browser to server are AJAX requests.

Note: you can add selenide and selenium dependencies using Studio: Project properties - Edit - Advanced

Example of UI test using selenide:


import org.junit.Test;
import static com.codeborne.selenide.Condition.visible;
import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.Selenide.open;
import static org.openqa.selenium.By.xpath;

public class LoginUiTest {
    @Test
    public void defaultLogin() {
        open("[url=http://localhost:8080/app]http://localhost:8080/app"[/url]);

        $(xpath("//*[@cuba-id='loginSubmitButton']")).shouldBe(visible).click();
    }
}

I’ve attached the simple project with sample UI test using selenide, so you can see UI testing of CUBA application in action. (The sample test uses default selenium browser, so you need to have installed Firefox)

ui-test-deps

ui-test.zip (20.3K)

cuba-id-attribute

1 Like

Thanks a lot for the detailed answer, I will certainly try this.