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

Asked

Viewed 137 times

2

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

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

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 page of Qunit’s website there are examples of DOM manipulation tests (if an element has become visible after a user action, etc.)

It turns out that testing the interface seems to be quite laborious, I really don’t know if it’s worth it.

It is recommended to create automated tests for the interface, or this we should test "at hand" even?

  • I will try to post a better answer, see for example the Zombiejs and the cucumberJs, together allow to create a good coverage of tests using BDD is an idea to have tests with interface and with not so much effort

1 answer

1


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

*"Must": all "must" here are relative as this will depend on numerous variables in your environment. But while you still don’t know from your own 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.

  • Good article. I’ve never heard of Test Pyramid before.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.