Testing is a critical aspect in any software development process. For effective testing, a test suite with substantial test coverage is required. A test suite is a set of test cases, which is used to validate that a program behaves in a certain way. A common problem regarding test suites is that they are not seen as part of the system, and therefore are not always given the same attention as production code with regards to proper development practices. A software engineering principle that is often compromised is the principle of generality, which involves writing code as general as possible, allowing it to be reused. In practice, breaking this principle can mean that much of the test suite consists of similar test cases that have the potential to be generalised. The problem of many similar cases is often due to the fact that much test design is done by copying old test cases and changing them. (Eldh, 2022). A result of this is that many test suites are unnecessarily large, and take longer to execute due to their size.

A way to generalise the methods in a test suite is through refactoring. Refactoring is the process of changing the syntax of something without changing its semantics. This can be advantageous for readability, maintainability and general code quality. Refactoring can be used on test suites with similar or overlapping test cases by restructuring the similar cases into a single test case, where the subtle differences between them instead are sent as parameters. After restructuring, one must test whether the tests give the same results, as changed behaviour would mean a failed refactoring and the changes would have to be reverted. Doing this refactoring manually is possible, but a more efficient way to do it would be using a tool that automatically analyses and refactors a test suite. An automatic tool like this could reduce the size of a test suite, which could effectivize test suite execution. Decreasing the time spent on executing the test suite would help to facilitate many modern software development processes which rely on testing, such as test-driven development. The question addressed in the thesis is

Can the size of test suites in Python be reduced through automated refactoring?

Methodology

To test the thesis statement, the thesis will develip a tool to automatically refactor given test suites. It will used in run experiments applying it to test suites from open source projects on GitHub, then checking whether the behaviour of the tests changed, in addition to checking whether the size of the test suite changed.