Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UI testing vs unit testing

what is the different purpose of those both? I mean, in which condition I should do each of them?

as for the example condition. if you have the backend server and several front-end webs, which one you'll do?do-unit testing the backend server first or do-UI testing in the web UI first? given the condition, the server and the front-end webs already exist, so it's not an iterative design to build along with (TDD)...

like image 271
haris hamdani Avatar asked Mar 02 '11 10:03

haris hamdani


2 Answers

Unit testing aims to test small portions of your code (individual classes / methods) in isolation from the rest of the world.

UI testing may be a different name for system / functional / acceptance testing, where you test the whole system together to ensure it does what it is supposed to do under real life circumstances. (Unless by UI testing you mean usability / look & feel etc. testing, which is typically constrained to details on the UI.)

You need both of these in most of projects, but at different times: unit testing during development (ideally from the very beginning, TDD style), and UI testing somewhat later, once you actually have some complete end-to-end functionality to test.

If you already have the system running, but no tests, practically you have legacy code. Strive to get the best test coverage achievable with the least effort first, which means high level functional tests. Adding unit tests is needed too, but it takes much more effort and starts to pay back later.

Recommended reading: Working Effectively with Legacy Code.

like image 136
Péter Török Avatar answered Oct 12 '22 17:10

Péter Török


Unit test should always be done. Unittests are there to provide proof that each UNIT (read: object) of your technical solution delivers the expected results. To put it very (maybe too) simple, user testing is there to verify that your system fulfills the needs and demands of the user.

like image 39
Morten Avatar answered Oct 12 '22 17:10

Morten