持续改进:是否可以预先指定测试?

时间:2018-10-23 12:42:45

标签: testing continuous-integration specifications

我习惯于“老式”瀑布开发周期。 对于一个新项目,持续集成似乎更适合我们的需求。

在瀑布中,您必须预先指定要实施的测试。

我的问题:

  • 关于测试规范的持续集成开发周期的通常方式是什么?
  • 如果您不指定测试,可以设想一种预先指定测试的方法吗?

非常感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

在大学里,我们被教导说“测试驱动的开发”是有道理的,特别是如果有适当的编码规范。

如果您不能在编码之前编写测试->编码规范应该更具体/有问题。

我通常根据Java类的编码规范编写单元测试,然后将其集成到我们的jenkins连续集成服务器上并执行。

如果我错了,请原谅我,但这就是我学到的...

它总是取决于所需的Java类的复杂性,琐碎的“域”类不需要大的规范info

在大多数情况下,我们尝试指定类或方法的工作方式(用文字),并写下一些示例值。

让我们说您应该编写一种方法来检查值是否在指定范围内:

// Example Specification:
// the method 'checkIfItsInRange' should return true when : the input lies within the range and it should be devidable by the distance value 
// Lets say the range goes from -30,00 to +30,00 with a distance from 0,25
// valid values :30, -30, 15.25, 15.50, 17.75 etc. -> return true
// invalid : -31, -30.01, +30.08, 0.4 etc. -> return false
// MissingParameterException when one of the Parameters is null

public boolean checkIfItsInRange throws MissingParameterException (BigDecimal from, BigDecimal to, BigDecimal distance, BigDecimal input) {
        // TODO implement depending on spec.
}

在这种情况下,您可以在开始实现方法本身之前就已经编写了一些单元测试。

我希望这可以使事情变得更清楚。