Unit Testing - Falmouth-Games-Academy/comp350-research-journal GitHub Wiki
Definition
Unit testing is a method by which individual sets of source code are programmed to perform within a controlled environment. The environment is set up so that bugs are easily reproducible and performance changes cannot be attributed to external factors. The aim of these tests is to determine whether the source code sets are fit for use 1(https://www.researchgate.net/publication/4377732_Automated_Defect_Prevention_Best_Practices_in_Software_Management). There are two main unit testing approaches Automated and Manual 4(https://www.guru99.com/unit-testing-guide.html#2). Unit testing isn't that useful in games according to 7(https://grumpygamer.com/unit_testing_games) who claims that most of the bugs from his his experience come from game logic being wrong and says that doing unit tests is hard to test this because failure states are hard to identify this way.
Types of Unit Testing
Automatic unit testing is use a program or a separate piece of code to test another piece of code or programming software. They usually tend to be created and executed by the developer of the code being tested unlike GUI testing which would be performed by a QA specialist. Automated testing is well suited to tests such as Measuring Performance and Regression Testing. Manual testing is where a person will directly test a piece of software often performing many of the tasks the end user would want to perform. Many professional testers insist that manual testing is just as important as unit testing even though the latter is more cost effective, the ability to perform exploratory testing being one of many reasons 8(https://dzone.com/articles/5-reasons-why-manual-testing-is-still-very-importa).
Measuring the results of Unit testing
When implementing Unit tests for a program, a common metric to use is code coverage (sometimes referred to as test coverage); code coverage is usually measured as a percentage. As the code coverage rises, you can assume the chances of bugs in a system to reduce 2(http://realsearchgroup.org/SEMaterials/tutorials/eclemma/). However, it is often emphasised that high code coverage does not always mean good quality testing 3(https://stackoverflow.com/questions/90002/what-is-a-reasonable-code-coverage-for-unit-tests-and-why (User Gishu)).
Issues with Unit Testing
A common problem with unit testing many sources like to list is that of integration 4(https://www.guru99.com/unit-testing-guide.html#2). To be more specific, they claim that Unit testing will not report any errors that may occur from the integration of two modules 4(https://www.guru99.com/unit-testing-guide.html#2). T .Xie et al 5(https://www.researchgate.net/profile/Tao_Xie13/publication/4272478_Towards_a_Framework_for_Differential_Unit_Testing_of_Object-Oriented_Programs/links/547c6fe50cf293e2da2dd6ab.pdf) use the term 'differential' unit testing, which refers to unit tests that can include one or more classes. This style of testing could be used to solve the problem highlighted in 4(https://www.guru99.com/unit-testing-guide.html#2). Shubham Nigam 6(https://www.quora.com/What-are-the-disadvantages-of-unit-testing) provides an image of the test cycle of a piece of software (see figure 1). In Figure 1, integration testing and unit testing are two separate stages, which would suggest the proposed method by T .Xie et al 5(https://www.researchgate.net/profile/Tao_Xie13/publication/4272478_Towards_a_Framework_for_Differential_Unit_Testing_of_Object-Oriented_Programs/links/547c6fe50cf293e2da2dd6ab.pdf) is actually the combining of two existing methods.
Another issue with Unit Tests that is highlighted by Morgan Cheng 9(https://www.quora.com/What-are-some-problems-encountered-while-writing-unit-tests) is that the amount of tests that must be performed increases with the size of the code base. This results in test cases running for large amounts of time which becomes tedious for continuous integration.
A blog by Svitla Team10(https://svitla.com/blog/unit-testing) argues however, that for each hour spent on unit testing saves ten hours of troubleshooting later in the project. Which helps to justify the time spent on creating and executing Unit tests.
Figure 1
Resources
[1] D. Huizinga and A. Kolawa, Automated defect prevention: best practices in software management. John Wiley & Sons, 2007, pp.75.
[2] http://realsearchgroup.org/SEMaterials/tutorials/eclemma/
[3] https://stackoverflow.com/questions/90002/what-is-a-reasonable-code-coverage-for-unit-tests-and-why (User Gishu)
[4] https://www.guru99.com/unit-testing-guide.html#2
[5] Xie, Tao, et al. "Towards a framework for differential unit testing of object-oriented programs." Automation of Software Test, 2007. AST'07. Second International Workshop on. IEEE, 2007.
[6] https://www.quora.com/What-are-the-disadvantages-of-unit-testing
[7] https://grumpygamer.com/unit_testing_games
[8] https://dzone.com/articles/5-reasons-why-manual-testing-is-still-very-importa
[9] https://www.quora.com/What-are-some-problems-encountered-while-writing-unit-tests