Skip to content

Tag: Unit Test

Running unit tests in multiple environments

Posted in Code Snippets

Recently my fiancée, who works as a software test engineer, showed me the Selenium framework. I find it quite useful, as it makes automating the testing of web apps really easy with its Python library. Combined with the unittest lib readily available in every Python install, test cases can be written in a few lines of code.

One of the strengths of Selenium is that it can utilize multiple browsers, and abstracts them using webdrivers. So how should be already written test scripts modified, if they must be run with multiple browsers instead of a single one? Assuming that every test case is derived from a common parent class, which is, in turn, subclassed from unittest.TestCase, it turns out that only a few line of code must be changed.