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
