Mutex
Mutex

Reputation: 447

Logging in automation testing

Is there any reason to use logging in automated tests? I am asking because I have understanding that test must be readable and you shouldn't use any logging to bloat the code. It is also used to understand what is going on in app, so if it fails I know why (assert message) and if not - ok, I don't care what is in the test.

Thank you in advance.

Upvotes: 1

Views: 2335

Answers (1)

ekostadinov
ekostadinov

Reputation: 6950

You are right for this statement

test must be readable

since test code is production code. And the quality should be high, if not the same. But IMHO

shouldn't use any logging to bloat the code.

is not correct. If you run your automation tests on remote (physical or VM) server, you need some way to understand what happened in each step, where are the errors and warnings.

How do you troubleshoot or reproduce failed test only using stack trace and the latest Assertion message? Logging helps you avoid the common cause of Obscure Test - the Mystery Guest. You should be able to see the cause and effect between fixture and verification logic, without too much effort. Let's take a look at the Log4j home page

Logging equips the developer with detailed context for application failures. On the other hand, testing provides quality assurance and confidence in the application. Logging and testing should not be confused. They are complementary. When logging is wisely used, it can prove to be an essential tool.

I hope till now I've managed to convince at least one person that logging is a fundamental part of the automation tests.

Upvotes: 2

Related Questions