Just started on unit testing using Scala and had this basic question.
class Test {
ClassToBeTested testObject;
@Before
void initializeConstructor() {
testObject = new ClassToBeTested(//Blah parameters);
}
@Test
//Blah
}
The above example in Java shows that I can just declare an object of type ClassToBeTested
and initialize it later. Can this be done in Scala? I tried it
class Test {
var testObject = new ClassToBeTested()
@Before def initializeConstructor() {
//I do not know how to proceed here!!!!!!
}
@Test def testOne() {
//Some test
}
}
I don't want to do everything inside the testOne()
because I want to use the object in different tests. The parameters of the constructor are mocks and in JUnit
I know that mocks are not initialized if I initialize an object globally and not inside @Before
.