Approach to automate verify large text file (logs) with cucumber from www site checked with selenium webdriver

Viewed 440

I am currently working on a project and I am looking for a way to automate the programming system. In a nutshell, the project works in this way: some operations on the frontend (www site) call and generate logs (with a lot of content) and now I analyze the logs manually but I would like to automate this process.

I have a question for you how to approach this process in the simplest way, I am currently learning java and for now, I wrote scripts in selenium webdriver + java and cucumber. And here is my question whether using cucumber I could also add assertions to verify logs? if so, how?

At the moment I have three ways to verify my logs:

  1. after performing some operations on the website, reading a file with logs from the location on the C drive of my computer and verify if there is a corresponding string in the file.
  2. Performing all operations on the frontend and generating full logs, and then comparing them with the template file with logs (one that is tested manually and it is certain that the entire page functionality works correctly)
  3. I am also thinking about such a solution to download a text file in time eg. in a loop such as 20 seconds and check if there is the desired string in it and then in the cucumber is considered assertion.

I am asking for advice from more experienced colleagues.

For all the tips, I will be very grateful!

Greetings, Chris

1 Answers

I would separate out the testing of logging from the testing of business functionality. With logging there are two main things you might want to check

  1. That an operation causes a log entry to be written
  2. That the content of a particular log entry is correct

You can do this at a very low level very fast with a unit test around each log call that your code makes. This will give you a suite of a large number of very tests each one testing that one log entry is made.

If you continue with your current approach you will be running integration tests (which will be much much slower) where each business action generates large amounts of logging. Some of that logging will be your logging but lots of it will probably be logging from your platform, which you don't need to test. This approach is error prone, complex and does not give very good value.

Related