0
试图学习一些Scala。构造函数的参数太多
我在我的项目中的以下类:
package com.fluentaws
class AwsProvider(val accountId: String, val accountSecret: String) {
def AwsAccount = new AwsAccount(accountId, accountSecret)
}
class AwsAccount(val accountId : String, val accountSecret : String) {
}
而且下面的测试:
package com.fluentaws
import org.scalatest._
class AwsProvider extends FunSuite {
test("When providing AwsProvider with AWS Credentials we can retrieve an AwsAccount with the same values") {
val awsAccountId = "abc"
val awsAccountSecret = "secret"
val awsProvider = new AwsProvider(awsAccountId, awsAccountSecret)
val awsAccount = awsProvider.AwsAccount
assert(awsAccount.accountId == awsAccountId)
assert(awsAccount.accountSecret == awsAccountSecret)
}
}
当我的测试套件运行时,我得到的编译时错误:
too many arguments for constructor AwsProvider: ()com.fluentaws.AwsProvider [error] val awsProvider = new AwsProvider(awsAccountId, awsAccountSecret) [error]
从错误消息,它看起来像它看到一个零参数的构造函数?
任何人都可以看到我在做什么错在这里?
哦,..也许我正在重新定义一个名为AwsProvider的新类,而不是扩展现有的类 – CodeMonkey
您应该重命名您的测试类。 – tkausl
是的,就是这样:-) – CodeMonkey