scala測試框架:scalatest


api文檔:http://tool.oschina.net/apidocs/apidoc?api=scalatest-1.7.2

trait Assertions:http://tool.oschina.net/apidocs/apidoc?api=scalatest-1.7.2

traitFunSuite:http://tool.oschina.net/apidocs/apidoc?api=scalatest-1.7.2

請看代碼片段一和二的區別:這里有很多規定寫法。

代碼片段一:是一個測試套,根據名字SetSuite識別。在IDEA中執行的時候,你可以選擇執行整個測試套(包含2個用例),或者執行執行測試套的某個用例

package org.scalatest.examples.funsuite

import org.scalatest.FunSuite

class SetSuite extends FunSuite {

  test("An empty Set should have size 0") {
    assert(Set.empty.size === 0)
  }

  test("Invoking head on an empty Set should produce NoSuchElementException") {
    intercept[NoSuchElementException] {
      Set.empty.head
    }
  }
}

 

 代碼片段二:是一個測試用例,根據名字SetTest識別。在IDEA執行的時候,只會執行一個測試用例setTest,測試用例的名字是固定寫法

package org.scalatest.examples.funsuite

import org.scalatest.FunSuite

class SetTest extends FunSuite {

  test("setTest") {
    assert(Set.empty.size === 0)
  }

  test("setTest1") {
    intercept[NoSuchElementException] {
      Set.empty.head
    }
  }
}

 

 

 

 

 

參考:

http://orchome.com/246

http://www.scalatest.org/quick_start

https://www.jianshu.com/p/ceabf3437dd7


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM