由于各种原因,我最近完成了一个将复杂的财务应用程序从C#转换为Java的项目。 港口的原因大部分是非技术性的,相反,这是有关企业的一项战略举措。
这是一次有趣的经历,我在此过程中吸取了一些经验教训,可以分享这些经验。
1.在现有系统上构建语言中立的测试。
我将从最重要的一课开始。 移植系统时,由于任何原因它可能是任何端口,因此必须具有确定该端口是否成功的标准。 最好的方法是围绕原始系统构建一整套测试,这些测试可以“ 无需更改就导出”到新系统。 因此,例如,如果要将系统从Java迁移到不支持JUnit的其他语言,则没有一套JUnit测试是不好的。 我不能过分强调测试的更改从字面上可以从旧系统复制到新系统而无需干预的重要性,这是多么重要。
JUnit测试的另一个问题是它们通常与现有的实现紧密地联系在一起。 由于将要重写实现,因此测试无法在实现之间移植。
我们选择的并且非常有效的策略是使用Cucumber测试。 几乎所有语言都有Cucumber的绑定,IDE(至少是IntelliJ和Visual Studio都)很好地支持了Cucumber,此外,该测试是人类可读的。 这样,您可以让非技术用户参与测试的准备工作,以准备端口。 (顺便说一句,我们试图通过记录