Specs2"value in不是String的成员"

 怡智俊婷珮婷 发布于 2022-12-04 01:03

我无法编译简单的specs2 hello world示例:

import org.junit.runner.RunWith
import org.specs2.Specification
import org.specs2.runner.JUnitRunner

import org.specs2.mutable._

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

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

得到错误:

:compileTestScala [ant:scalac]元素'/ home/~~~~/workspaces/~~~~/build/resources/main'不存在.
[ant:scalac] /home/~~~~/workspaces/~~~~/src/test/scala/com/~~~~/ingestion/SampleTest.scala:16:错误:值in不是
{
[ant:scalac]中的字符串[ant:scalac]"包含11个字符" 发现一个错误
:compileTestScala FAILED

我正在使用Gradle(因此是@RunWith注释).使用specs2版本'org.specs2:specs2_2.10:2.4.15'

apply plugin: 'java'
apply plugin: 'scala'

repositories {
    mavenCentral()
    maven {
        url "http://dl.bintray.com/scalaz/releases"
    }
}

configurations {
    provided
    compile.extendsFrom provided
}

dependencies {
    provided 'org.apache.hadoop:hadoop-client:2.2.0'

    compile 'org.scala-lang:scala-library:2.10.0',
            'com.twitter:scalding-core_2.10:0.12.0',
            'com.github.scopt:scopt_2.10:3.2.0',
            'org.json4s:json4s-jackson_2.10:3.2.11',

            'args4j:args4j:2.0.29',
            'joda-time:joda-time:2.4',
            'log4j:log4j:1.2.17',
            'org.apache.commons:commons-compress:1.9',
            'org.apache.commons:commons-lang3:3.3.2',
            'org.codehaus.jackson:jackson-core-asl:1.9.13'


    testCompile 'junit:junit:4.11',
                'org.mockito:mockito-all:1.9.5',
                'org.specs2:specs2_2.10:2.4.15'
}

jar {
    dependsOn configurations.runtime
    from {
        (configurations.compile - configurations.provided).collect {
            it.isDirectory() ? it : zipTree(it) 
        }
    }
}

stew.. 14

你需要扩展org.specs2.mutable.Specification而不是org.specs2.Specification语法.

1 个回答
  • 你需要扩展org.specs2.mutable.Specification而不是org.specs2.Specification语法.

    2022-12-11 02:15 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有