小编Bil*_*ure的帖子

运行简单测试时ScalaTest DeferredAbortedSuite错误.

我的原始代码还有很多,这让我分心了问题的真正原因.这抓住了基本问题.

import org.scalatest.AsyncFlatSpec
import scala.concurrent.Future

class AsyncFlatSpecSpec extends AsyncFlatSpec
{
  it should "parse an XML file" in {
    // ... Parsing ...
    Future.successful(succeed)
  }

  it should "parse an XML file" in {
    // ... Serializing ...
    Future.successful(succeed)
  }
}
Run Code Online (Sandbox Code Playgroud)

这产生了以下错误:

[info] DeferredAbortedSuite:
[error] Uncaught exception when running AsyncFlatSpecSpec: java.lang.ArrayIndexOutOfBoundsException: 17
[trace] Stack trace suppressed: run last test:testOnly for the full output.
Run Code Online (Sandbox Code Playgroud)

我的代码中没有任何数组访问发生.这是怎么回事?

运行"最后一次测试:testOnly"没有多大帮助:

[info] DeferredAbortedSuite:
[error] Uncaught exception when running AsyncFlatSpecSpec: java.lang.ArrayIndexOutOfBoundsException: 17
sbt.ForkMain$ForkError: java.lang.ArrayIndexOutOfBoundsException: 17
  at org.scalatest.exceptions.StackDepth$class.stackTraceElement(StackDepth.scala:63)
  at org.scalatest.exceptions.StackDepth$class.failedCodeFileName(StackDepth.scala:77) …
Run Code Online (Sandbox Code Playgroud)

unit-testing scala scalatest

12
推荐指数
1
解决办法
3213
查看次数

Anorm String Interpolation 不替换变量

我们正在使用 Scala Play,我试图确保所有 SQL 查询都使用 Anorm 的字符串插值。它适用于某些查询,但许多查询实际上并没有在执行查询之前替换变量。

import anorm.SQL
import anorm.SqlStringInterpolation

object SecureFile 
{
  val table = "secure_file"
  val pk = "secure_file_idx"
  ...

// This method works exactly as I would hope
def insert(secureFile: SecureFile): Option[Long] = {
  DBExec { implicit connection =>
    SQL"""
      INSERT INTO secure_file (
        subscriber_idx,
        mime_type,
        file_size_bytes,
        portal_msg_idx
      ) VALUES (
        ${secureFile.subscriberIdx},
        ${secureFile.mimeType},
        ${secureFile.fileSizeBytes},
        ${secureFile.portalMsgIdx}
        )
      """ executeInsert()
    }
  }

def delete(secureFileIdx: Long): Int = {
  DBExec { implicit connection =>
    // Prints correct values
    println(s"table: …
Run Code Online (Sandbox Code Playgroud)

scala anorm playframework-2.3

3
推荐指数
1
解决办法
1171
查看次数