最新的测试通过但实际上没有工作

时间:2014-11-06 10:22:27

标签: scala playframework scalatest

这是我的scalatest文件,测试savedat method.savedat在我的表中输入一个Employeeentry对象并返回保存的行数,在我的情况下是1:

class databasetest extends FlatSpec  { 
    "this" should "save a row in table" in new App{
        DB.withSession{ implicit session : Session => 
            Employee.savedat(EmployeeEntry(1,"james","bhagat","ghgas"))
        }
    }
}

1 个答案:

答案 0 :(得分:0)

这有效:

class databasetest extends Specification {

"this" should {

  // val appWithMemoryDatabase = FakeApplication(additionalConfiguration = inMemoryDatabase("test"))

     "test savedat" in new WithApplication {


         DB.withSession{

             implicit session :Session => 

             Employee.savedat(EmployeeEntry(45,"ketan","bhagat","ghgas")) must be equalTo (1)

         }


     }

错误是Play经常要求正在运行的应用程序作为WithApplication对象提供的上下文。