sacalatest AnyFunSuite:no implicits found for parameter pos

Idea 中 如果加载scalatest的jar包后,一切顺利,当你写下如下代码的时候,会提示你no implicits found for parameter pos在test(){..}(这里报错)。查了各种资料都没有怎么填pos这个位置的方法。且示例都不用写pos。
例如如下示例是可以运行的:

import org.scalatest.funsuite

class MyTest extends funsuite.AnyFunSuite {
  val s = "a b c d"
  test("长度大于4"){
    assert(s.length > 4)
  }
}

报错原因

新建的是scala工程,仅导入一个scalatest-funsuite_2.11-3.2.0.jar的包是不够的,还要导入scalatest-compatible-3.2.0.jar和scalatest-core_2.11-3.2.0.jar包。这样才有pos的隐式转换能力。

更简单的方法

改建scala的pom工程,然后加如下依赖即可,工程会自动加载funsuite,core,compatible 包

  <dependencies>
    <dependency>
      <groupId>org.scalatest</groupId>
      <artifactId>scalatest-funsuite_2.11</artifactId>
      <version>3.2.0</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值