Tests related to the patcher are located in the PatchTest class. Having in mind that I will need to write plenty of tests to cover as many corner cases as possible I started to think how to make the job a little bit easier. This is when the idea of the "testPatchdataSubfolders" came to my mind. I thought it would be great if one could test the patcher by simply adding a directory with some files in it (as this what writing patch test is actually all about). So now what I need to do is create a subfolder in the "patchdata" folder (e.g. "196847" for bug number 196847). To properly run the test a specific set of file need to be place inside the subfolder:
- context.txt - this is an original file
- patch.txt - this is a patch we would like to apply
- expected_context.txt - this is an expected result of the patch applied
- actual_context.txt - this is an actual result after applying the patch
The other idea I had to test the patcher was to write a fully automated test class. The class could change a file content according to some algorithm or given parameters. The change couldn't be random as a possible failure need to be reproducible. Here are the steps:
- Create a project with a file and share it
- Make a change in the file
- Create a diff (patch) for the file
- Override and update the file (revert to previous version)
- Apply the patch and check if it's the same as in 1.
- Go to 2.