使用JUnitRunner和规范进行scala单元测试
我正在用scala在我的游戏框架上运行测试。使用JUnitRunner和规范进行scala单元测试,scala,junit,playframework-2.1,Scala,Junit,Playframework 2.1,我正在用scala在我的游戏框架上运行测试。 我有一个带有一些测试的scala类,它们都是这样的: @RunWith(classOf[JUnitRunner]) class UpdateProductTest extends Specification { abstract class WithDbData extends WithApplication { } "Product DB Repository" should { //This is tes
我有一个带有一些测试的scala类,它们都是这样的:
@RunWith(classOf[JUnitRunner])
class UpdateProductTest extends Specification
{
abstract class WithDbData extends WithApplication {
}
"Product DB Repository" should
{
//This is test #1 !
"add product with minimal fields" in new WithDbData
{
val name = Some(LocalizedItem(IdGenerator.newId, "testName"))
val description = Some(LocalizedItem(IdGenerator.newId, "testDescription"))
val product = new Product(Option(IdGenerator.newId), "defaultTestName", "defaultTestDescription",
Some(1), None, None, None,
None, new References(Some("1"), Some("1"), Some("1"), Some("1")), None, None,
name,description, None)
val productRepository = new ProductDbRepositoryImpl()
productRepository.addProduct("en_US", "1", product)
}
}
"Product DB Repository" should // <= i wish to run only this test and ignore the test above!!
{
val image1:ProductImage = new ProductImage(java.util.UUID.randomUUID().toString, Some("high resultion"), Some("url to image 1"), Some(1))
val image2:ProductImage = new ProductImage(java.util.UUID.randomUUID().toString, Some("low resolution"), Some("url to image 2"), Some(1))
//This is test #2 !
"add product with minimal fields and images" in new WithDbData
{
.....
}
@RunWith(classOf[JUnitRunner])
类UpdateProductTest扩展了规范
{
抽象类WithDbData扩展WithApplication{
}
“产品数据库存储库”应
{
//这是测试1!
在new WithDbData中“添加具有最小字段的产品”
{
val name=Some(LocalizedItem(IdGenerator.newId,“testName”))
val description=Some(LocalizedItem(IdGenerator.newId,“testDescription”))
val product=新产品(选项(IdGenerator.newId)、“defaultTestName”、“defaultTestDescription”,
一些(1),没有,没有,没有,
无,新引用文件(部分(“1”)、部分(“1”)、部分(“1”)、部分(“1”)、无、无,
名称、说明、无)
val productRepository=new ProductDbRepositoryImpl()
productRepository.addProduct(“en_US”,“1”,产品)
}
}
“产品数据库存储库”应//