DEV Community

Should I test at the GUI Level or the API Level?

Alan Richardson on April 14, 2017

TLDR; Where to test? Can you isolate the functionality? If so, test the isolation most heavily. Then look to see what integrates, and how it inte...
Collapse
 
stealthmusic profile image
Jan Wedel

I'm not sure why it even makes sense to distinguish API/UI from other types of tests if you're developing a system / services full stack. This makes it even harder. You'll have to consider:

  • Backend Unit Tests
  • Backend Integration Tests (Service Level, not external dependencies)
  • Backend Service Test (Aka Service System tests or API, with external dependencies e.g. Real DB)
  • Backend System Test (aka System Test)
  • Frontend Unit Tests
  • Frontend Integration Tests with Backend Mocks
  • Frontend Systemtests with real system

For both back and frontend, the more business benefit (unit < integration < system) them more effort it is to write tests for all use and edge cases.

We are developing test driven, so unit tests are of no question. Then we are moving to use spring boot integration tests for most of the heavy load stuff (DB, MQ, REST) because it's so stunningly easy to write those tests. Then we have the main use cases modeled as end-to-end system tests for both UI and Backend.

Collapse
 
danielscarvalho profile image
Daniel de Souza Carvalho

I like to use JUnit to test my classes and them QUnit to test services (unit testing) those are very similar test tools, it helps a lot at the dev cycle, not just to validate the code.

Moreover, take care with "sample" data in dev environment, it is trick! Tests go ok in dev environment and fail in production with the full dataset!

For UI and more advanced tests call a tester! To test is not simple, do not underestimate tests! Testers are really crazy people! They come um for example with sophisticated test tools such as "mutation code testing", this is something that the devs are not really going to do by hand!