• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala JUnitRunner类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中org.specs2.runner.JUnitRunner的典型用法代码示例。如果您正苦于以下问题:Scala JUnitRunner类的具体用法?Scala JUnitRunner怎么用?Scala JUnitRunner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了JUnitRunner类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)

} 
开发者ID:astonbitecode,项目名称:kind-of-di,代码行数:55,代码来源:ConstructorsPopulationSpec.scala


示例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 
  }

} 
开发者ID:carrot-garden,项目名称:vendor_ibrk_fibs-scala,代码行数:59,代码来源:OCAGroupSpec.scala


示例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"
  }
} 
开发者ID:carrot-garden,项目名称:vendor_ibrk_fibs-scala,代码行数:43,代码来源:MarketOnCloseOrderSpec.scala


示例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"
  }
} 
开发者ID:carrot-garden,项目名称:vendor_ibrk_fibs-scala,代码行数:50,代码来源:LimitOrderSpec.scala


示例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"
  }
} 
开发者ID:carrot-garden,项目名称:vendor_ibrk_fibs-scala,代码行数:50,代码来源:TrailStopOrderSpec.scala


示例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)
    }
  }
} 
开发者ID:ciscox83,项目名称:PostMeEasy,代码行数:21,代码来源:NotFoundPageTest.scala


示例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)
    }
  }
} 
开发者ID:ciscox83,项目名称:PostMeEasy,代码行数:20,代码来源:IndexPageTest.scala


示例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"
    }
  }
} 
开发者ID:aarwee,项目名称:PLAY-SLICK-DEEPTI-KUNAL-RISHABH,代码行数:56,代码来源:AwardsRepoSpec.scala


示例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"))
    }
  }
} 
开发者ID:PallaviSingh1992,项目名称:Play-Slick-Assig2-v2,代码行数:50,代码来源:AwardRepoTest.scala


示例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"))
    }


  }

} 
开发者ID:PallaviSingh1992,项目名称:Play-Slick-Assig2-v2,代码行数:54,代码来源:LanguageRepoTest.scala


示例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
    }
  }
} 
开发者ID:PallaviSingh1992,项目名称:Play-Slick-Assig2-v2,代码行数:49,代码来源:UserRepoTest.scala


示例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"))
    }
  }

} 
开发者ID:PallaviSingh1992,项目名称:Play-Slick-Assig2-v2,代码行数:53,代码来源:AssignmentRepoTest.scala


示例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++"))

    }

  }

} 
开发者ID:PallaviSingh1992,项目名称:Play-Slick-Assig2-v2,代码行数:55,代码来源:ProgLanguageRepoTest.scala


示例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)
  }
} 
开发者ID:mubeenahmed,项目名称:MeGuideApi,代码行数:25,代码来源:UserTest.scala


示例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
      }
    }

  }

} 
开发者ID:mibexsoftware,项目名称:shipit2marketplace,代码行数:45,代码来源:UtilsTest.scala


示例16: ArtifactDeploymentIdSpec

//设置package包名称以及导入依赖的类
package ch.mibex.bamboo.shipit.task.artifact

import ch.mibex.bamboo.shipit.task.artifacts.{ArtifactDownloaderTaskId, ArtifactSubscriptionId}
import org.junit.runner.RunWith
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner


@RunWith(classOf[JUnitRunner])
class ArtifactDeploymentIdSpec extends Specification {

  "unapply with an artifact ID and a name" should {

    "yield a artifact subscription ID" in {
      "123:XYZ" match {
        case ArtifactSubscriptionId(artifactId, artifactName) =>
          artifactId must_== 123
          artifactName must_== "XYZ"
        case _ => false must_== true
      }
    }

  }

  "unapply with an artifact ID, a name, a downloader task ID and a transfer ID" should {

    "yield a artifact downloader task ID" in {
      "123:XYZ:456:789" match {
        case ArtifactDownloaderTaskId(artifactId, artifactName, downloaderTaskId, transferId) =>
          artifactId must_== 123
          artifactName must_== "XYZ"
          downloaderTaskId must_== 456
          transferId must_== 789
        case _ => false must_== true
      }
    }

  }

} 
开发者ID:mibexsoftware,项目名称:shipit2marketplace,代码行数:41,代码来源:ArtifactDeploymentIdSpec.scala


示例17: MpacFacadeTest

//设置package包名称以及导入依赖的类
package ch.mibex.bamboo.shipit.mpac

import com.atlassian.marketplace.client.MarketplaceClient
import com.atlassian.marketplace.client.api.AddonQuery
import org.junit.runner.RunWith
import org.mockito.Answers._
import org.mockito.Mockito.withSettings
import org.specs2.mock.Mockito
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner
import org.specs2.specification.Scope


@RunWith(classOf[JUnitRunner])
class MpacFacadeTest extends Specification with Mockito {

  "find plug-in by key" should {

    "yield none if unknown" in new PluginNotFoundContext {
      client.findPlugin("UNKNOWN PLUGIN") must beRight(None)
    }

  }

  class PluginNotFoundContext extends Scope {
    val mpac = mock[MarketplaceClient](withSettings.defaultAnswer(RETURNS_DEEP_STUBS.get))
    // val plugin = mock[Plugin] // we cannot mock Plugin as it is final
    mpac.addons().getByKey(anyString, any[AddonQuery]) returns com.atlassian.fugue.Option.none()
    val client = new MpacFacade(mpac)
  }

} 
开发者ID:mibexsoftware,项目名称:shipit2marketplace,代码行数:33,代码来源:MpacFacadeTest.scala


示例18: DragonServletTest

//设置package包名称以及导入依赖的类
package org.blinkmob.scalatraseed

import org.junit.runner.RunWith
import org.scalatra.test.specs2.ScalatraSpec
import org.specs2.runner.JUnitRunner
import org.json4s.jackson.Serialization._
import org.json4s.DefaultFormats
import org.json4s.Formats

@RunWith(classOf[JUnitRunner])
class DragonServletTest extends ScalatraSpec {
  implicit val jsonFormats: Formats = DefaultFormats
  
  def is = s2"""
    GET /dragon
      gets you some sweet dragons $getDragons
  """
      
  addServlet(new DragonServlet, "/dragon")
  
  def getDragons = get("/dragon"){
    val resp = read[List[Dragon]](response.body)
    resp must contain(Dragon(1, "BLUE", "Saphira"), Dragon(2, "GREEN", "Puff"))
  }
} 
开发者ID:gnomff,项目名称:scalatra-sangria,代码行数:26,代码来源:DragonServletTest.scala


示例19: Specs2NameTest

//设置package包名称以及导入依赖的类
package com.nekopiano.scala.sandbox.test;

import org.specs2.mutable._
import org.specs2.specification.BeforeAfterExample
import org.specs2.specification.Example
import org.specs2.specification.ExampleFactory
import org.junit.runner.RunWith
import org.specs2.runner.JUnitRunner

@RunWith(classOf[JUnitRunner])
class Specs2NameTest extends Specification {
  override def is =
    "testabc" ! {
      ok
    }
  case class BeforeAfterExample(e: Example) extends BeforeAfter {
    def before = println("before " + e.desc)
    def after = println("after " + e.desc)
  }
  override def exampleFactory = new ExampleFactory {
    def newExample(e: Example) = {
      val context = BeforeAfterExample(e)
      e.copy(body = () => context(e.body()))
    }
  }
} 
开发者ID:lamusique,项目名称:ScalaSandbox,代码行数:27,代码来源:Specs2NameTest.scala


示例20: Specs2Test

//设置package包名称以及导入依赖的类
package com.nekopiano.scala.sandbox.test;

import org.specs2.mutable._
import org.specs2.runner.JUnitRunner
import org.junit.runner.RunWith
import org.specs2.specification.Example
import org.specs2.specification.ExampleFactory
import org.specs2.specification.BeforeAfterExample

@RunWith(classOf[JUnitRunner])
class Specs2Test extends Specification with BeforeAfterExample {

  var currentExample = 0
  var testName = ""

  "The 'Hello world' string" should {
    "contain 11 characters" in {
      "Hello world" must have size (11)
    }
    "start with 'Hello'" in {
      "Hello world" must startWith("Hello")
    }
    "end with 'world'" in {
      "Hello world" must endWith("world")
    }
  }

  "Test name" should {
    "by example" in {
      val testName = is.examples(0).desc.toString.replaceAll(" ", "-")
      println("testName=" + testName)
      true must beTrue
    }
    "by thread" in {
      val st = Thread.currentThread.getStackTrace.asInstanceOf[Array[StackTraceElement]]
      println("st=" + st(1))
      true must beTrue
    }
  }

  def before {
    testName = is.examples(currentExample).desc.toString.replaceAll(" ", "-")
      println("before testName=" + testName)
  }

  def after {
    currentExample += 1
  }
} 
开发者ID:lamusique,项目名称:ScalaSandbox,代码行数:50,代码来源:Specs2Test.scala



注:本文中的org.specs2.runner.JUnitRunner类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala Escalate类代码示例发布时间:2022-05-23
下一篇:
Scala WSPut类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap