Unit Testing and Integration Testing with Robot and Cucumber
Alberto last edited by
I understand that both frameworks are great for acceptance testing but how hard or more complex is writing lower level tests such as integration tests or unit tests using the mentioned frameworks when compared to domain specific frameworks such as Gtest and jUnit?
I am specifically asking for C++ or Java projects. But answers regarding other projects are also appreciated.
DL;DR: It's possible, but you shouldn't.
All the tools you've mentioned are essentially test runners, meaning they execute a DSL focused on test code in someway.
JUnit and GoogleTest execute methods according to a code-based instruction*, have class/method-level mocking support, and do reporting.
On the other hand, Cucumber and Robot are focused on executing methods based on a semi-structured files written in human language, and do reporting.
In the end of the day, all of them simply execute methods you define, but the highlighted points already show the main goal of each test runner.
Code is always unambiguous - using it to describe a small piece of code behavior (a unit) is the natural way. However, for "bigger" behaviors, human language can be more beneficial.
But only for these "bigger" behaviors": Describe every single piece of work necessary to execute in isolation a small functionality is bloated - unit test runners already come with some features for creating some level of abstraction, such as @Before/@After hooks
* TestNG, e.g., uses XML