Skip to content

mvysny/karibu-testing-spring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Powered By Vaadin on Kotlin Build Status

Karibu-Testing Demo project for Spring Boot

A Vaadin 8 example project which demonstrates the possibility to use the Karibu-Testing Browserless Testing Framework with Spring Boot. No web server, no Selenium, and no TestBench, pure business logic testing.

For Vaadin 14 example project please visit t-shirt-shop-example.

Either Java or Kotlin might be used, or both. Testing the Vaadin 8 application is as easy as:

Java:

    @Test
    public void createNewCustomer() {
        _click(_get(Button.class, spec -> spec.withCaption("New customer")));
        _setValue(_get(TextField.class, spec -> spec.withCaption("First name")), "Halk");
        _click(_get(Button.class, spec -> spec.withCaption("Save")));
        Grid<Customer> grid = _get(Grid.class);
        Stream<Customer> customerStream = grid.getDataProvider().fetch(new Query<>());
        assertTrue("Halk does not exist", customerStream.map(Customer::getFirstName).anyMatch("Halk"::equals));
    }

Kotlin:

    @Test
    fun createNewCustomer() {
        _get<Button> { caption = "New customer" }._click()
        _get<TextField> { caption = "First name" }._value = "Halk"
        _get<Button> { caption = "Save" }._click()
        val dataProvider = _get<Grid<Customer>> { }.dataProvider
        expect(true, "Halk does not exist: ${dataProvider._findAll()}") {
            dataProvider._findAll().any { it.firstName == "Halk" }
        }
    }

Workflow

To compile the entire project, run ./mvnw -C clean package (or on Windows: ./mvnw.cmd -C clean package).

To run the application, run ./mvnw spring-boot:run and open http://localhost:8080/.

To run the tests, run ./mvnw verify.

About

Karibu-Testing Demo project for Spring Boot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published