Trying to learn some Scala.
I have the following classes in my project:
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) {
}
And the following test:
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)
}
}
When my test-suite runs, I get the compile-time error:
too many arguments for constructor AwsProvider: ()com.fluentaws.AwsProvider [error] val awsProvider = new AwsProvider(awsAccountId, awsAccountSecret) [error]
From the error message it looks like it sees a constructor with zero parameters ?
Can anyone see what I am doing wrong here ?
It was a typical rookie mistake. I fixed my test-class' name, because using the same name would shadow the original name, whereby I was actually testing my test's class:
package com.fluentaws
import org.scalatest._
class AwsProviderTestSuite 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)
}
}
Now it passes.