scala - Using @Inject annotation causes var to be recognized as a @Test? -
@test class mytestclass { @inject var myinjectedvar: mycontroller = _ @test def mytest = { ... } } when use intellij, javax, , testng run tests in mytestclass, mytest gets run expect, output shows additional test doesn't run properly:
org.testng.testngexception: method myinjectedvar_$eq requires 1 parameters 0 supplied in @test annotation. somehow, @inject annotation above appears creating method named myinjectedvar_$eq, , testng expecting able run if had been annotated @test.
how inject myinjectedvar without testng expecting test?
remove @test annotation class:
class mytestclass { @inject var myinjectedvar: mycontroller = _ @test def mytest = { ... } } see testng documentation details: http://testng.org/doc/documentation-main.html#class-level
the effect of class level @test annotation make public methods of class become test methods if not annotated. can still repeat @test annotation on method if want add attributes.
the methods myinjectedvar_=(v: mycontroller): unit , myinjectedvar(): mycontroller methods generated scala compiler. scala uses these methods access var.
Comments
Post a Comment