2014-05-23 1 views
0

누구나 내 문장 보고서에이 문장을 어떻게 나타낼 수 있습니까?조건이 확인 된 경우에도 ScalaTest가 통과하지 않습니다.

"는 (배열 (109, 121, 75, 101, 121)) 목록에 동등하지 않았다 (어레이 (109, 121, 75, 101, 121))에서"여기

전체

출력

Run starting. Expected test count is: 4 
Ws2redisAdapterTest: 
Ws2redisAdapter 
- should recognize 1-arity commands 
- should recognize 2-arity commands *** FAILED *** 
    List(Array(109, 121, 75, 101, 121)) was not equal to List(Array(109, 121, 75, 101, 121)) (Ws2redisAdapterTest.scala:15) 
- should recognize N-arity commands *** FAILED *** 
    List(Array(109, 121, 90, 115, 101, 116), Array(48), Array(45, 49)) was not equal to List(Array(109, 121, 90, 115, 101, 116), Array(48), Array(45, 49)) (Ws2redisAdapterTest.scala: 
21) 
- should throw Exception if an empty string is popped 
Run completed in 298 milliseconds. 
Total number of tests run: 4 
Suites: completed 1, aborted 0 
Tests: succeeded 2, failed 2, canceled 0, ignored 0, pending 0 
*** 2 TESTS FAILED *** 

이 코드에서 내 시험이다 :

package eu.codesigner.finagle.ws2redis 
import org.scalatest._ 

class Ws2redisAdapterTest extends FlatSpec with Matchers { 

    "Ws2redisAdapter" should "recognize 1-arity commands " in { 
    val (cmd, args) = Ws2redisAdapter.adaptRedisCommand("INFO") 
    cmd should be("INFO") 
    args should be(null) 
    } 

    it should "recognize 2-arity commands " in { 
    val (cmd, args) = Ws2redisAdapter.adaptRedisCommand("GET myKey") 
    cmd should be("GET") 
    args should be(List("myKey".getBytes())) 
    } 

    it should "recognize N-arity commands " in { 
    val (cmd, args) = Ws2redisAdapter.adaptRedisCommand("ZRANGE myZset 0 -1") 
     cmd should be("ZRANGE") 
     args should be(List("myZset".getBytes(),"0".getBytes(), "-1".getBytes())) 
    } 

    it should "throw Exception if an empty string is given" in { 
    a[Exception] should be thrownBy { 
     Ws2redisAdapter.adaptRedisCommand("") 
    } 
    } 
} 

답변

2

평등이 배열에 전용 (자바처럼) 참조 평등으로 정의된다. 따라서 테스트가 실패합니다. 두 배열의 동등성을 java.util.Arrays.equals으로 확인할 수 있습니다.

+0

젠장, 이것은 신참 실수 였어! :) "해야한다"여전히 사용할 수있게하려면 바이트 배열을지도의 문자열로 변환하는 테스트를 수정해야합니다. 여기에서 args는 (목록 ("myKey".getBytes()) 이어야합니다. args.map (새 문자열 (_))은 (List ("myKey")이어야합니다. – sscarduzio