Automated Testing For NetSuite Development

What is automated testing?

Automating testing is the process of testing a system or piece of software automatically without the need to have a person, or user, take time to test it themselves. It also allows the same test to be run multiple times if needed and the testing process will not change by accident or user error.

Why use automated testing?

Here at 3EN we use automated testing on our different Glance apps (Hello, Book, and View). This enables us to make small changes and updates to our apps to improve them, and then test that they still work correctly automatically. If we get a notification that a test fails we can go have a look at where the test failed and easily correct the problem. It’s a lot quicker than having someone review the code and test the functionality every time a change is made, taking up their time while they could be working on something else.

How we use automated testing

We use a piece of software called IntelliJ IDEA CE for writing our tests in Selenium Java. Since all out apps integrate with our NetSuite system we have developed the 3EN WebDriver, this allows us to manipulate the NetSuite UI via code to run our tests. Below is an example of our 3EN WebDriver.

NetSuiteAuthentication netSuiteAuthentication = new NetSuiteAuthentication();
netSuiteAuthentication.setCompany("");
netSuiteAuthentication.setEmail("");
netSuiteAuthentication.setPassword("");
netSuiteAuthentication.setRole("");
netSuiteAuthentication.setNetsuiteBaseUrl("");

website.login(netSuiteAuthentication);

The code above, with the relevant information added, would be used to access the NetSuite home page of the desired role. This allows us to check that our Glance apps are working properly within NetSuite.

For example, our Book app allows us to book meetings in specified rooms in our office, once we book a meeting we can then check the Calendar in NetSuite for the booked meeting to see if all the information from the Book app is the same as the information in NetSuite.

This example is us choosing the name of the meeting organiser on the Book app;

Element bookRoomOrganiserName = homePage.getBookRoomOrganiserName().find();
String bookOrganiserName = bookRoomOrganiserName.getText();
bookRoomOrganiserName.getWebElement().click();

Another example is how our Book app gets used with one of our other apps, View, when a meeting is booked. With View being our dashboard app, it can display meeting times, when meeting rooms are busy, when meeting rooms will be free again, and when a meeting room will no longer be free.

This is an example of us choosing the start time of the meeting which has been set to 18:00;

Element bookRoomStartTimeHours = homePage.getBookRoomStartTimeHours().find();
bookRoomStartTimeHours.getWebElement().click();

Element bookRoomStartTimeMinutes = homePage.getBookRoomStartTimeMinutes().find();
bookRoomStartTimeMinutes.getWebElement().click();

And this is how we test, checking to make sure the dashboard displays that the meeting room is available until this time;

Element nimbusText = dashboardPage.getNimbusText().find(); Assert.assertTrue(nimbusText.getText().contains("Nimbus is free until")); Element nimbusTime = dashboardPage.getNimbusTime().find(); Assert.assertTrue(nimbusTime.getText().contains("6:00 pm"));

A lot of the code we use for the automated testing is reusable such as the login processes for all the apps. We use methods in our tests to make the code look cleaner and less take up less memory.

For example, this would be a simple method we would use for logging into our Hello app;

HomePage homePage = getHomePage();

And this would be the method that this is calling;

private HomePage getHomePage() {
    loginToHello("username", "password");

    waitForHomePageToLoad();

    return getHelloWebsite().getHomePage();
}

This method would be used in practically every one of our Hello tests, having reusable code put into a method makes it easier to manage. If something is wrong with the code, you only need to fix it once.

I hope this gave you an inside look at how 3EN use automated testing to ensure our Glance apps are working perfectly with everything they are connected to. As well as how we minimise the use of space by using reusable methods in our code.

 

To stay in the loop for further news, guides, resources and more, sign up to "insight" our flagship weekly NetSuite and Business Software Newsletter, click here.