1
我在运行测试时遇到了一些问题,它使用TestNg的@DataProvider向scala中编写的测试提供数据。这是我到目前为止。在Scala中使用TestNG @DataProvider
import org.testng.annotations._
import org.testng.Assert
import org.scalatest.testng.TestNGSuite
import java.lang.Boolean
class PieceTest extends TestNGSuite {
@DataProvider(name= "pieceMovesProvider")
def pieceMovesProvider() = {
Array[Object](Array[Object](BISHOP, Position(0,0), Position(1,1), Boolean.TRUE))
}
@Test(dataProvider = "pieceMovesProvider")
def testCanTake(piece: Piece, from: Position, to: Position, result: Boolean) = {
Assert.assertEquals(result, piece.canTake(from, to))
//Moves should be commutative
Assert.assertEquals(result, piece.canTake(to, from))
}
@Test def hello() = {
print(1)
}
}
当我运行测试的Hello测试通过,但其他测试将被跳过,没有错误或交代。任何想法发生了什么?
正确的,它的对象[] [],对应于你的测试方法 – 2010-12-10 18:44:09
的参数,每个阵列是否有必要甚至明确指出,这是一个数组[对象]呢?我在想在这里推断的类型应该没问题。 – 2010-12-10 22:32:19