Skip to content

Writer Helper

Colin Wisdom edited this page Apr 27, 2022 · 2 revisions

Writer Helper

With in the tests folder is the writer_helper.py file. This file contains a class that's only purpose is to make writing new test methods easier.

Pytest does not require test classes to inherent any Base Test class. Fixtures replace the need for such things. A drawback to this is that when developing new test methods, the test class that contains them does not have access to the Page Objects. Without this recall the IDE can not suggest or autocomplete the methods in those objects.

I created a workaround for this by creating a Writing class that initializes the various Page Objects to be used by the Test classes.

Examples:

With Out the Writer Helper

image

No suggestions are given

With the Writer Helper

image

Suggested methods are listed

This saves time having to write out each method and reduces errors from spelling mistakes or just not remembering the exact wording. Also lets you see the parameters for the methods.

image

ALWAYS REMOVE THE WRITER CLASS FROM THE TEST CLASS WHEN NOT ACTIVALLY DEVELOPING NEW TEST

Pytest will fail to collect the tests if the Test class is inheriting any other classes. class TestClass: when running class TestClass(Writer): when developing.

NEVER COMMIT CODE CHANGES WITH THE WRITER CLASS IN USE!!!

Clone this wiki locally