From my experience I can say that usually UI test automation framework is a separate code base, different from developers repository (application under test).
It is common to use Maven or Gradle as a build tool in test automation frameworks written on Java. By default it means that the project has main
and test
subfolders, which is know as “Maven Standard Directory Layout”.
For developers code it is clear: under main
there is application code itself, whereas under test
there are unit tests. But for the test automation framework I can feel there are different opinions:
- Tests. Test automation framework is considered as nothing but the tests. All code goes under
test
subfolder. Themain
subfolder is empty. - App. Test automation framework is a separate application. The purpose of the application is testing, statistics, reporting, etc., but in this case it doesn’t matter. As we usually do not write unit tests for our automation tests, then the
test
subfolder is empty, all code is inmain
subfolder. - Automation and testing. In test automation we should distinguish “automation” and “testing” parts. Automation part (framework initialization, drivers, page objects, constants that describe application under test, etc.) goes under
main
. Testing part (assertions, tests, before/after hooks, constants that represent test data, etc.) goes undertest
.
I can suggest advantages and disadvantages for each approach:
- Tests. This is the easiest, but having empty
main
looks strange. Do we test nothing? Somebody may think it means that the developers repository can be used instead of separate one. - App. This looks for me very logical. But I have never see it in my projects. I also not sure whether test automation frameworks like JUnit or TestNG are absolutely ok with that.
- Automation and testing. It seems to me very consistent with the official docs, for example, Selenium documentation insists that page object are about automation, rather than testing, so no assertions should be there. So this approach looks like logical continuation. But the disadvantage that I can feel is an uncertainty. It is clear that page objects (without assertions) should be under
main
. Tests itself should be undertest
. But I’m afraid about more ambiguous situations. What if the test automation structure also consists of business logic layer. Where should be that layer? Especially if it has verification steps (with assertions)?
I would be very happy if you share your experience and describe what and why you consider the best!
Thanks!