Steps to take to slowly integrate unit-testing into a project

后端 未结 4 890
情歌与酒
情歌与酒 2021-02-06 11:33

I\'m currently on a co-op term working on a project nearing completion with one other co-op student. Since this project has been passed down from co-op to co-op, poor practices

4条回答
  •  我寻月下人不归
    2021-02-06 12:03

    It's very difficult to start new development practises mid way through a project. In the past when I've worked on projects that haven't been unit tested from the start, a good approach to take is to set down the rule that 'new code must have unit tests' but don't put pressure on unit tests being written for old code.

    Of course, even this is difficult when the structure of the project is not suited to testability.

    My best recommendation would be take it in small steps.

    Start by creating your unit test assembly, (or project or whatever) with no tests in it. Then find a single small area of code that is fairly well defined and seperated, and write some unit tests for that area. Get your co-coder to take a look too and start getting some 'best practises' going, like running the unit tests every time any code is checked in (automatically if possible).

    Once you have that working, you can slowly start to add more.

    The key is slowly. And like I said, it's easier to make old code exempt from the testing to begin with. You can always return to it later once your team has grasped the idea of unit testing and has become better at writing them.

提交回复
热议问题