2016-11-21 7 views
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]

エラーメッセージから、パラメータがゼロのコンストラクタが表示されているようですか?

私はここで間違っているのを誰も見ることができますか?

+0

私はAwsProviderという新しいクラスを再定義していて、既存のクラスを拡張していないかもしれません – CodeMonkey

+2

テストクラスの名前を変更する必要があります。 – tkausl

+0

ええ、それはそれでした:-) – CodeMonkey

答えて

2

これは典型的なルーキーミスです。

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

} 

は、今では渡し:私は実際に私のテストのクラスをテストしたところ、同じ名前を使用すると、元の名前を影になるので、私は、私のテスト・クラスの名前を修正しました。

関連する問題