Avoiding merge conflicts by test-based task prioritization - ROCHA, Thaís Alves Burity (2020)
In a collaborative development context, merge conflicts might compromise software quality and developers’ productivity. To reduce conflicts, one could avoid the parallel execution of programming tasks that are likely to change the same files. Although hopeful, this strategy is challenging because it relies on the prediction of the required file changes to complete a task. As predicting file changes is hard, we investigate its feasibility for BDD (Behaviour-Driven Development) projects, which write automated acceptance tests before implementing features. We develop a tool that, for a given task, statically analyzes Cucumber tests and conservatively infers test-based interfaces or TestI (files that could be executed by the tests), approximating files that would be changed by the task. To assess the accuracy of this approximation, we measure precision and recall of test-based interfaces of 513 tasks from 18 Rails projects on GitHub. We also compare such interfaces with randomly defined interfaces, interfaces obtained by the textual similarity of test specifications with past tasks, and interfaces computed by executing tests. Our results give evidence that, in the specific context of BDD, Cucumber tests might help to predict files changed by tasks. We find that the better the test coverage, the better the predictive power. Next, we evaluate whether it is possible to predict the risk of a merge conflict when integrating the code produced by two programming tasks based on the intersection among their TestI. To assess the predictions of conflict risk, we measure precision and recall of 6,360 task pairs from 19 Rails projects on GitHub. Our results confirm that Cucumber tests might help to predict the risk of merge conflicts, given the intersection among interfaces denotes a higher probability that the tasks change some file in common. A minimal intersection predicts conflict risk with 0.59 of precision and 0.98 of recall. Also, the higher the intersection size, the higher the number of files changed by both tasks. This way, developers might use the intersection size between TestI as a degree of conflict risk between tasks, prioritizing the selection of a task to work on whose TestI has the lowest intersection with others. Finally, a predictor of conflict risk based on TestI outperforms a predictor based on similar past tasks.