本文整理汇总了Scala中org.specs2.runner.JUnitRunner类的典型用法代码示例。如果您正苦于以下问题:Scala JUnitRunner类的具体用法?Scala JUnitRunner怎么用?Scala JUnitRunner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JUnitRunner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: ConstructorsPopulationSpec
//设置package包名称以及导入依赖的类
package com.github.astonbitecode.di
import java.util.concurrent.TimeUnit
import scala.concurrent.Await
import scala.concurrent.duration.FiniteDuration
import org.junit.runner.RunWith
import org.specs2.mutable
import org.specs2.runner.JUnitRunner
import org.specs2.specification.BeforeEach
@RunWith(classOf[JUnitRunner])
class ConstructorsPopulationSpec extends mutable.Specification with BeforeEach {
val timeout = FiniteDuration(1000, TimeUnit.MILLISECONDS)
override def before() {
TestUtil.clean
}
sequential
"A spec for the Constructors population in the DI ".txt
"A constructor should be populated in the DI" >> {
val f = diDefine { () => MyInjectableClass("One") }
Await.result(f, timeout)
cache must haveSize(1)
}
"A constructor should be replaced in the DI if it already exists" >> {
val f1 = diDefine { () => MyInjectableClass("One") }
Await.result(f1, timeout)
val f2 = diDefine { () => MyInjectableClass("Two") }
Await.result(f2, timeout)
cache must haveSize(1)
cache.head._2.constructor.apply().asInstanceOf[MyInjectableClass].id === "Two"
}
"A constructor with scope SINGLETON_EAGER should create the instance upon the call" >> {
val f = diDefine(() => MyInjectableClass("One"), DIScope.SINGLETON_EAGER)
Await.result(f, timeout)
cache must haveSize(1)
cache.head._2.cachedInstance.isDefined === true
}
"A constructor with scope SINGLETON_LAZY should not create the instance upon the call" >> {
val f = diDefine(() => MyInjectableClass("One"), DIScope.SINGLETON_LAZY)
Await.result(f, timeout)
cache must haveSize(1)
cache.head._2.cachedInstance.isDefined === false
}
case class MyInjectableClass(id: String)
}
示例2: OCAGroupSpec
//设置package包名称以及导入依赖的类
package name.kaeding.fibs
package order
import org.junit.runner.RunWith
import org.specs2.runner.{ JUnitRunner }
import org.specs2._
import org.scalacheck._
import Arbitrary._
import scalaz._, Scalaz._
import contract._
import order.{Order => FibsOrder, _}
import OrderAction._
import ib.messages._
import ib.impl._
import ib.impl.HasIBOrder._
import com.ib.client.{ Order => IBOrder }
import TestData._
@RunWith(classOf[JUnitRunner])
class OCAGroupSpec extends Specification with ScalaCheck { def is =
"OCAGroup converted to IBOrder must" ^
"represent each input order" ! exEachOrder^
"have an OCA name" ! exOcaGroupHasName^
"have the same OCA Group name" ! exOcaGroupSameName^
"have a distinct OCA Group name from another OCA group" ! exOcaGroupDistinctName^
"have the right OCA type" ! exOcaTypeMatches^
end
def exEachOrder = prop { (os: List[FibsOrder[Stock]], ocaName: String, ocaType: OCAType) =>
val oca = os.foldLeft(OCA: OCAGroup)((oca, o) => o :: oca)
oca.ibOrders(ocaName, ocaType).map(_.apply(-1)).map(o => (o._2.action, o._2.totalQuantity)) must containTheSameElementsAs(
os.map(o => (o.action.shows, o.qty)))
}
def exOcaGroupHasName = prop { (os: NonEmptyList[FibsOrder[Stock]], ocaName: String, ocaType: OCAType) =>
val oca = os.foldLeft(OCA: OCAGroup)((oca, o) => o :: oca)
oca.ibOrders(ocaName, ocaType).map(_.apply(-1)).map(o => Option(o._2.ocaGroup)) must contain(beSome(ocaName)).forall
}
def exOcaGroupSameName = prop { (os: List[FibsOrder[Stock]], ocaName: String, ocaType: OCAType) =>
val oca = os.foldLeft(OCA: OCAGroup)((oca, o) => o :: oca)
oca.ibOrders(ocaName, ocaType).map(_.apply(-1)).map(o => Option(o._2.ocaGroup)).distinct.length must be_<(2)
}
def exOcaGroupDistinctName = prop { (os: NonEmptyList[FibsOrder[Stock]], ocaName1: String, ocaType: OCAType) =>
val oca1 = os.foldLeft(OCA: OCAGroup)((oca, o) => o :: oca)
val oca2 = os.foldLeft(OCA: OCAGroup)((oca, o) => o :: oca)
oca1.ibOrders(ocaName1, ocaType).map(_.apply(-1)).map(o => Option(o._2.ocaGroup)).distinct must_!=
oca2.ibOrders(ocaName1 + "-2", ocaType).map(_.apply(-1)).map(o => Option(o._2.ocaGroup)).distinct
}
def exOcaTypeMatches = prop { (os: NonEmptyList[FibsOrder[Stock]], ocaName: String, ocaType: OCAType) =>
val oca = os.foldLeft(OCA: OCAGroup)((oca, o) => o :: oca)
// oca.ibOrders(ocaName, ocaType).map(_.apply(-1)).map(o => Option(o._2.ocaType)) must contain(beSome(OCAType.code(ocaType))).forall
}
}
示例3: MarketOnCloseOrderSpec
//设置package包名称以及导入依赖的类
package name.kaeding.fibs
package order
import org.junit.runner.RunWith
import org.specs2.runner.{ JUnitRunner }
import org.specs2._
import org.scalacheck._
import Arbitrary._
import scalaz._, Scalaz._
import contract._
import ib.impl.HasIBOrder
import ib.impl.HasIBOrder._
import com.ib.client.{ Order => IBOrder }
import TestData._
@RunWith(classOf[JUnitRunner])
class MarketOnCloseOrderSpec extends Specification with ScalaCheck { def is =
"MarketOnCloseOrder converted to IBOrder must" ^
"retain the action" ! exAction^
"retain the quantity" ! exQuantity^
"have the correct order type" ! exOrderType^
end
def exAction = prop { (o: MarketOnCloseOrder[Stock], orderId: Int) =>
val hasIb = implicitly[HasIBOrder[Stock, MarketOnCloseOrder]]
val ibo: IBOrder = hasIb.ibOrder(o, orderId)
ibo.action must_== o.action.shows
}
def exQuantity = prop { (o: MarketOnCloseOrder[Stock], orderId: Int) =>
val hasIb = implicitly[HasIBOrder[Stock, MarketOnCloseOrder]]
val ibo: IBOrder = hasIb.ibOrder(o, orderId)
ibo.totalQuantity must_== o.qty
}
def exOrderType = prop { (o: MarketOnCloseOrder[Stock], orderId: Int) =>
val hasIb = implicitly[HasIBOrder[Stock, MarketOnCloseOrder]]
val ibo: IBOrder = hasIb.ibOrder(o, orderId)
ibo.orderType must_== "MOC"
}
}
示例4: LimitOrderSpec
//设置package包名称以及导入依赖的类
package name.kaeding.fibs
package order
import org.junit.runner.RunWith
import org.specs2.runner.{ JUnitRunner }
import org.specs2._
import org.scalacheck._
import Arbitrary._
import scalaz._, Scalaz._
import contract._
import ib.impl.HasIBOrder
import ib.impl.HasIBOrder._
import com.ib.client.{ Order => IBOrder }
import TestData._
@RunWith(classOf[JUnitRunner])
class LimitOrderSpec extends Specification with ScalaCheck { def is =
"LimitOrder converted to IBOrder must" ^
"retain the action" ! exAction^
"retain the limit price" ! exLimitPrice^
"retain the quantity" ! exQuantity^
"have the correct order type" ! exOrderType^
end
def exAction = prop { (o: LimitOrder[Stock], orderId: Int) =>
val hasIb = implicitly[HasIBOrder[Stock, LimitOrder]]
val ibo: IBOrder = hasIb.ibOrder(o, orderId)
ibo.action must_== o.action.shows
}
def exLimitPrice = prop { (o: LimitOrder[Stock], orderId: Int) =>
val hasIb = implicitly[HasIBOrder[Stock, LimitOrder]]
val ibo: IBOrder = hasIb.ibOrder(o, orderId)
ibo.lmtPrice must_== o.limit
}
def exQuantity = prop { (o: LimitOrder[Stock], orderId: Int) =>
val hasIb = implicitly[HasIBOrder[Stock, LimitOrder]]
val ibo: IBOrder = hasIb.ibOrder(o, orderId)
ibo.totalQuantity must_== o.qty
}
def exOrderType = prop { (o: LimitOrder[Stock], orderId: Int) =>
val hasIb = implicitly[HasIBOrder[Stock, LimitOrder]]
val ibo: IBOrder = hasIb.ibOrder(o, orderId)
ibo.orderType must_== "LMT"
}
}
示例5: TrailStopOrderSpec
//设置package包名称以及导入依赖的类
package name.kaeding.fibs
package order
import org.junit.runner.RunWith
import org.specs2.runner.{ JUnitRunner }
import org.specs2._
import org.scalacheck._
import Arbitrary._
import scalaz._, Scalaz._
import contract._
import ib.impl.HasIBOrder
import ib.impl.HasIBOrder._
import com.ib.client.{ Order => IBOrder }
import TestData._
@RunWith(classOf[JUnitRunner])
class TrailStopOrderSpec extends Specification with ScalaCheck { def is =
"TrailStopOrder converted to IBOrder must" ^
"retain the action" ! exAction^
"retain the trail amount" ! exTrailAmt^
"retain the quantity" ! exQuantity^
"have the correct order type" ! exOrderType^
end
def exAction = prop { (o: TrailStopOrder[Stock], orderId: Int) =>
val hasIb = implicitly[HasIBOrder[Stock, TrailStopOrder]]
val ibo: IBOrder = hasIb.ibOrder(o, orderId)
ibo.action must_== o.action.shows
}
def exTrailAmt = prop { (o: TrailStopOrder[Stock], orderId: Int) =>
val hasIb = implicitly[HasIBOrder[Stock, TrailStopOrder]]
val ibo: IBOrder = hasIb.ibOrder(o, orderId)
ibo.auxPrice must_== o.trail
}
def exQuantity = prop { (o: TrailStopOrder[Stock], orderId: Int) =>
val hasIb = implicitly[HasIBOrder[Stock, TrailStopOrder]]
val ibo: IBOrder = hasIb.ibOrder(o, orderId)
ibo.totalQuantity must_== o.qty
}
def exOrderType = prop { (o: TrailStopOrder[Stock], orderId: Int) =>
val hasIb = implicitly[HasIBOrder[Stock, TrailStopOrder]]
val ibo: IBOrder = hasIb.ibOrder(o, orderId)
ibo.orderType must_== "TRAIL"
}
}
示例6: NotFoundPageTest
//设置package包名称以及导入依赖的类
package functional
import me.cs.easypost.Constants
import me.cs.easypost.models.RootModel
import org.junit.runner.RunWith
import org.specs2.runner.JUnitRunner
import play.api.test.{PlaySpecification, WithBrowser}
@RunWith(classOf[JUnitRunner])
class NotFoundPageTest extends PlaySpecification {
val rootModel = new RootModel
"Application" should {
"Display Action Not Found on a bad request" in new WithBrowser {
browser.goTo("/boum")
browser.$(rootModel.TitleId).getTexts().get(0) must equalTo(Constants.ActionNotFound)
}
}
}
示例7: IndexPageTest
//设置package包名称以及导入依赖的类
package me.cs.easypost
import me.cs.easypost.models.RootModel
import org.junit.runner.RunWith
import org.specs2.runner.JUnitRunner
import play.api.test.{PlaySpecification, WithBrowser}
@RunWith(classOf[JUnitRunner])
class IndexPageTest extends PlaySpecification {
val rootModel = new RootModel
"Application" should {
"display correctly the index page" in new WithBrowser {
browser.goTo("/")
browser.$(rootModel.TitleId).getTexts().get(0) must equalTo(rootModel.Title)
}
}
}
示例8: AwardsRepoSpec
//设置package包名称以及导入依赖的类
package repo
import models.AwardsRepo
import org.junit.runner.RunWith
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner
import play.api.Application
import play.api.test.WithApplication
import scala.concurrent.Await
import scala.concurrent.duration.Duration
@RunWith(classOf[JUnitRunner])
class AwardsRepoSpec extends Specification {
sequential
def awardsRepo(implicit app: Application) = Application.instanceCache[AwardsRepo].apply(app)
"Awards repository" should {
"get a record" in new WithApplication {
val result = awardsRepo.getAll
val response = Await.result(result, Duration.Inf)
response.head.name === "microsoft"
}
"delete a record" in new WithApplication {
val result = awardsRepo.delete(2)
val response = Await.result(result, Duration.Inf)
response === 1
}
"add a record" in new WithApplication {
val result = awardsRepo.add("scjp", "good", "2015", 1)
val response = Await.result(result, Duration.Inf)
response === 1
}
"UPDATE a record" in new WithApplication {
val result = awardsRepo.update(2, "NCR Certificate", "worst", "2016", 3)
val response = Await.result(result, Duration.Inf)
response === 1
}
"get a record by id" in new WithApplication {
val result = awardsRepo.getById(2)
val response = Await.result(result, Duration.Inf)
response.get.name === "sun certificate"
}
"get a record by User id" in new WithApplication {
val result = awardsRepo.getByUserId(1)
val response = Await.result(result, Duration.Inf)
response.head.name === "microsoft"
}
}
}
示例9: AwardRepoTest
//设置package包名称以及导入依赖的类
package repository
import models.Award
import org.junit.runner.RunWith
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner
import play.api.Application
import play.api.test.WithApplication
import scala.concurrent.Await
import scala.concurrent.duration.Duration
@RunWith(classOf[JUnitRunner])
class AwardRepoTest extends Specification{
def awardRepo(implicit app:Application)=Application.instanceCache[AwardRepo].apply(app)
"Award Repository" should {
"get award records" in new WithApplication {
val res = awardRepo.getAll()
val response = Await.result(res, Duration.Inf)
response.head.id ===1
}
"insert award records" in new WithApplication() {
val res=awardRepo.insert(4,"best orator","school level")
val response=Await.result(res,Duration.Inf)
response===1
}
"update award records" in new WithApplication{
val res=awardRepo.update(1,"best singer","school level")
val response=Await.result(res,Duration.Inf)
response===0
}
"delete award records" in new WithApplication() {
val res=awardRepo.delete("best dancer")
val response=Await.result(res,Duration.Inf)
response===0
}
"get awards by id" in new WithApplication() {
val res=awardRepo.getAward(1)
val response=Await.result(res,Duration.Inf)
response===Vector(Award(1,"best programmer","school level"))
}
}
}
示例10: LanguageRepoTest
//设置package包名称以及导入依赖的类
package repository
import models.Language
import org.junit.runner.RunWith
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner
import play.api.Application
import play.api.test.WithApplication
import scala.concurrent.Await
import scala.concurrent.duration.Duration
@RunWith(classOf[JUnitRunner])
class LanguageRepoTest extends Specification{
def langRepo(implicit app:Application)=Application.instanceCache[LanguageRepo].apply(app)
"Language Repository" should {
"get language records" in new WithApplication {
val res = langRepo.getAll()
val response = Await.result(res, Duration.Inf)
response.head.id ===1
}
"insert language records" in new WithApplication() {
val res=langRepo.insert(1,"french","basic")
val response=Await.result(res,Duration.Inf)
response===1
}
"update language records" in new WithApplication(){
val res=langRepo.update(1,"spansih","basic")
val response=Await.result(res,Duration.Inf)
response === 1
}
"delete language record" in new WithApplication() {
val res=langRepo.delete("hindi")
val response=Await.result(res,Duration.Inf)
response===1
}
"get records by id" in new WithApplication() {
val res=langRepo.getLanguage(1)
val response=Await.result(res,Duration.Inf)
response===Vector(Language(1,"hindi","advanced"))
}
}
}
示例11: UserRepoTest
//设置package包名称以及导入依赖的类
package repository
import org.junit.runner.RunWith
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner
import play.api.Application
import play.api.test.WithApplication
import scala.concurrent.Await
import scala.concurrent.duration.Duration
@RunWith(classOf[JUnitRunner])
class UserRepoTest extends Specification {
def userRepo(implicit app:Application)=Application.instanceCache[UserRepo].apply(app)
"User Repository" should {
"get a student record" in new WithApplication {
val res=userRepo.getUser("himani[email protected]")
val response=Await.result(res,Duration.Inf)
response.head.name === "himani"
}
"get all student records" in new WithApplication() {
val res=userRepo.getAll()
val response=Await.result(res,Duration.Inf)
response.head.name==="himani"
}
"add student records" in new WithApplication{
val res=userRepo.insert(3,"santosh","[email protected]","72745690","santosh")
val response=Await.result(res,Duration.Inf)
response ===1
}
"delete student record" in new WithApplication{
val res=userRepo.delete(2)
val response=Await.result(res,Duration.Inf)
response ===1
}
"update student record" in new WithApplication() {
val res=userRepo.update(1,"simar","[email protected]","22469870","simar")
val response=Await.result(res,Duration.Inf)
response===1
}
}
}
示例12: AssignmentRepoTest
//设置package包名称以及导入依赖的类
package repository
import models.Assignment
import org.junit.runner.RunWith
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner
import play.api.Application
import play.api.test.WithApplication
import scala.concurrent.Await
import scala.concurrent.duration.Duration
@RunWith(classOf[JUnitRunner])
class AssignmentRepoTest extends Specification{
def assigRepo(implicit app:Application)=Application.instanceCache[AssignmentRepo].apply(app)
"Assignment Repository" should {
"get assignment records" in new WithApplication {
val res = assigRepo.getAll()
val response = Await.result(res, Duration.Inf)
response.head.id ===1
}
"insert assignment records" in new WithApplication() {
val res=assigRepo.insert(1,"slick",5,"no remark")
val response=Await.result(res,Duration.Inf)
response===1
}
"delete assignment record" in new WithApplication() {
val res=assigRepo.delete(1)
val response=Await.result(res,Duration.Inf)
response===1
}
"update assignment records" in new WithApplication(){
val res=assigRepo.update(1,"c++",7,"can do better")
val response=Await.result(res,Duration.Inf)
response === 1
}
"get assignment by id" in new WithApplication() {
val res=assigRepo.getAssignment(1)
val response=Await.result(res,Duration.Inf)
response===Vector(Assignment(1,"scala",7,"no remark"))
}
}
}
示例13: ProgLanguageRepoTest
//设置package包名称以及导入依赖的类
package repository
import models.ProgLanguage
import org.junit.runner.RunWith
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner
import play.api.Application
import play.api.test.WithApplication
import scala.concurrent.Await
import scala.concurrent.duration.Duration
@RunWith(classOf[JUnitRunner])
class ProgLanguageRepoTest extends Specification{
def plangRepo(implicit app:Application)=Application.instanceCache[ProgLanguageRepo].apply(app)
"Programming language Repository" should {
"get programming language records" in new WithApplication {
val res = plangRepo.getAll()
val response = Await.result(res, Duration.Inf)
response.head.id ===1
}
"insert programming language records" in new WithApplication() {
val res=plangRepo.insert(4,"c#")
val response=Await.result(res,Duration.Inf)
response===1
}
"update programming language records" in new WithApplication(){
val res=plangRepo.update(1,"java")
val response=Await.result(res,Duration.Inf)
response === 1
}
"delete programming language record" in new WithApplication() {
val res=plangRepo.delete("c++")
val response=Await.result(res,Duration.Inf)
response===1
}
"get a particular record" in new WithApplication{
val res=plangRepo.getProgLanguage(1)
val response=Await.result(res,Duration.Inf)
response===Vector(ProgLanguage(1,"c++"))
}
}
}
示例14: UserTest
//设置package包名称以及导入依赖的类
package database
import dal.repositories.authentication.{Authentication, AuthenticationRepository}
import org.junit.runner.RunWith
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner
import play.api.test.WithApplication
@RunWith(classOf[JUnitRunner])
class UserTest extends Specification {
"User must return id in string type" in new WithApplication {
val userAuth : AuthenticationRepository = new Authentication()
val id : String = userAuth getUserID("mubeen","abc") getOrElse("404")
assert(id == "58fa4ce3d1ba90513ed53651")
}
"User login is updated successfully" in new WithApplication {
val userAuth : AuthenticationRepository = new Authentication()
val affects = userAuth updateLogin("58fa4ce3d1ba90513ed53651")
assert(affects == 1)
}
}
示例15: UtilsTest
//设置package包名称以及导入依赖的类
package ch.mibex.bamboo.shipit
import java.io.File
import org.junit.runner.RunWith
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner
@RunWith(classOf[JUnitRunner])
class UtilsTest extends Specification {
"Utils" should {
"yield a build number padded with zeroes" in {
Utils.toBuildNumber("1.2.3") must_== 100200300
Utils.toBuildNumber("11.0.0") must_== 110000000
Utils.toBuildNumber("0.0.1") must_== 100
Utils.toBuildNumber("1.0") must_== 100000000
Utils.toBuildNumber("2.0") must_== 200000000
Utils.toBuildNumber("1.2.3-SNAPSHOT") must_== 100200300
}
"convert a Scala map to json" in {
Utils.map2Json(Map("test" -> Map("theAnswer" -> 42, "isTrue" -> true))) must_==
"""{"test":{"theAnswer":42,"isTrue":true}}"""
}
"convert json to Scala map" in {
Utils.mapFromJson("""{"test":{"theAnswer":42,"isTrue":true}}""") must_==
Map("test" -> Map("theAnswer" -> 42, "isTrue" -> true))
}
"find file by ant pattern" in {
val res = Utils.findMostRecentMatchingFile("**/*.zip", new File(getClass.getResource("/").toURI))
res match {
case Some(file) if file.getName == "bamboo-5.2-integration-test-home.zip" => true must_== true
case _ => true must_== false
}
}
}
}