Directory

← Back

tb-tools

A helper to build more stable integration tests

Author

Rating

Popularity

<100

A simple helper that automatically generates somewhat sane identifiers for components to help integration testing using real or simulated browsers. This includes tools like Vaadin TestBench, plain WebDriver, Gatling and JMeter.

The add-on works by doing inspection with reflection for given classes and assigns field names as identifiers for each component that don't contain explicit identifier. This way you for example have sane identifiers for all your fields in e.g. an entity editor ui component and this makes creating integration tests, and possibly also theme building, much easier.

Note, that as the component uses runtime inspection to do the "magic", it is not suggested to be kept active for application with really high scalability needs.

A simple use case can be seen in the projects tests, but you can also check out these example projects:

Sample code

    private MainPagePO mainPage;
    private FormPO form;

    @Test
    public void testClickButton() throws Exception {
        openTestUrl();

        Assert.assertFalse("Matti already filled!", mainPage.isValueInList(
                "Matti Tahvonen"));

        mainPage.clickNew();
        form.typeEmail("matti@vaadin.com");
        form.typeName("Matti Tahvonen");
        form.typeNumber("044 3029728");
        form.save();

        Assert.assertTrue("Saving failed", mainPage.isValueInList(
                "Matti Tahvonen"));

    }

    @Before
    public void setUp() throws Exception {
        setDriver(new FirefoxDriver());
        mainPage = PageFactory.initElements(driver, MainPagePO.class);
        form = PageFactory.initElements(driver, FormPO.class);
    }
/**
 * This page object contains Form related stuff
 */
public class FormPO {

    private WebElement name;
    private WebElement number;
    private WebElement email;
    private WebElement saveButton;
    
    public void typeName(String newName) {
        name.sendKeys(newName);
    }
    
    public void typeNumber(String newNr) {
        number.sendKeys(newNr);
    }
    
    public void typeEmail(String newEmail) {
        email.sendKeys(newEmail);
    }
    
    public void save() {
        saveButton.click();
    }

}

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Released
2014-11-11
Maturity
EXPERIMENTAL
License
Apache License 2.0

Compatibility

Framework
Vaadin 6.0+
Vaadin 7.3+
Browser
Browser Independent

tb-tools - Vaadin Add-on Directory

A helper to build more stable integration tests tb-tools - Vaadin Add-on Directory
A simple helper that automatically generates somewhat sane identifiers for components to help integration testing using real or simulated browsers. This includes tools like Vaadin TestBench, plain WebDriver, Gatling and JMeter. The add-on works by doing inspection with reflection for given classes and assigns field names as identifiers for each component that don't contain explicit identifier. This way you for example have sane identifiers for all your fields in e.g. an entity editor ui component and this makes creating integration tests, and possibly also theme building, much easier. Note, that as the component uses runtime inspection to do the "magic", it is not suggested to be kept active for application with really high scalability needs. A simple use case can be seen in the projects tests, but you can also check out these example projects:
Online