Is it advisable to write automated tests for the user interface?

2

When it comes to unit testing and TDD, we usually think of so-called "business logic" tests, which are based on requirements, etc.

But we also find examples of user interface testing on the web, especially on the web, but sometimes on the desktop.

Examples:

@Test public void shouldNavigateToPhotosPage() {
  String baseUrl = "http://plus.google.com/";
  Navigator nav = new Navigator(baseUrl);
  nav.goToPhotosPage();
  assertEquals(baseUrl + "/u/0/photos", nav.getCurrentUrl());
}
  • On the QUnit website pages there are examples of DOM manipulation tests (if an element became visible after a user action, etc.)

It turns out that testing the interface seems to be very labor-intensive, I really do not know if it's worth it.

Is it recommended to create automated tests for the interface, or should we test it on the spot?

    
asked by anonymous 12.09.2014 / 15:10

1 answer

1
  • Most of your automated tests should * be about your business rule (unit testing).
  • A smaller party should test the integration of these business rules with each other and with other layers of the system (service testing).
  • A small part should test your user interface where it is most critical to the business (UI).

* "Must": all "should" here are relative because this will depend on numerous variables in your environment. But as long as you still do not know from experience exactly what to do, follow the general instructions of those who have experienced this a lot and are willing to help.

I recommend reading this article: Martin Fowler - TestPyramid .

    
12.09.2014 / 19:00