这个测试的目标是取一个整数数组,找到最大值,并计算该最大值出现的频率。我将如何更改此代码以进行多次测试。另外,我想知道这是否是测试此问题的正确方法。
我是 TDD 的新手,目前正在练习编写测试以解决易于解决的练习问题。
谢谢!
import spock.lang.Specification
class BirthdayCandlesTest extends Specification {
def "GetNumberOfMaxHeightCandles"() {
given: "A BirthdayCandles object"
int[] test = [1,1,1,3,3,3,3]
def candles = new BirthdayCandles(test)
when: "I call the max number height method"
def result = candles.getNumberOfMaxHeightCandles()
then: "I should get the frequency count of the max number in the integer array"
result == 4
}
}
宝慕林4294392
潇湘沐
相关分类