My application requires the use of Spring. I have successfully configure Spring and my components/services are loaded when I run my test. However, I would very much like to make use of the HTML report feature. When I integrate Spring with my ScalaTest project my test cases don't seem to be "registered" with ScalaTest and their results are not included in the HTML report output.
As I compare a simple test case with Spring, to one without, it appears that the problem occurs because I am Autowiring my test cases.
@RunWith(classOf[JUnitRunner])
class PricingSpec extends FunSuite with TestSuite {
test("calculate load share") {
test1
}
@Autowired var test1 : TestCase1 = null
}
@ContextConfiguration( value = Array("/wpmClient-context.xml") )
@ActiveProfiles(Array("test"))
trait TestSuite extends BeforeAndAfterAll { this: Suite =>
@Autowired implicit var client: SessionState = null
@Autowired var testData: TestData = null
override def beforeAll: Unit = {
new TestContextManager(classOf[TestSuite]).prepareTestInstance(this)
super.beforeAll
}
override def afterAll: Unit = {
println(s"+== Cleaning up sample data...")
}
}
@Component
class TestCase1 @Autowired()(client: SessionState, testData: TestData)
extends PropSpec with Matchers with GivenWhenThen {
@Autowired private var blockLoad : BlockLoadService = _
property(s"""Test 1 descriptive text""") {
markup(s"""##Test Results Scenario: """)
assert(1===1)
}
}
*The Spring example above, initializes Spring and loads all of my beans but never runs TestCase1. TestCase1 is not listed in the Suite table of the HTML report.
TestCase1 is never run. I need TestCase1 to be instantiated by Spring as it requires access to various services that are also managed/instantiated by Spring. Any help on how I can make this work would be appreciated.