2010-12-10 20 views
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) 
    } 
} 

私はテストハローテストパスを実行しますが、他のテストがエラーまたは、について説明なしでスキップされます。何がここで何が起こっている考えですか?

答えて

1

データプロバイダの戻り値の型が間違っていました。それ

@DataProvider(name= "pieceMovesProvider") 
    def pieceMovesProvider() = { 
    Array(Array[Object](BISHOP, Position(0,0), Position(1,1), Boolean.TRUE)) 
    } 
+0

正しいされている必要があり、それは各アレイは、あなたの試験方法 –

+0

のパラメータに対応して、[] []オブジェクトのも、明示的にそれはすべてのアレイ[オブジェクト]だという状態には必要ですか?推測される型はここで大丈夫だと思っています。 –

関連する問題