I am very new to java and junit. I have sometest cases under test/pagetests like addTest.java , deleteTest.java. I have included these tests under junit test suite by using the code below
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
addTest.class,
deleteTest.class
})
public class JunitTestSuite {
}
All these test cases uses inputs from db. for this i have wrote a method called getValues in TestDBMethods.java which is in the path test/testdb which returns all the values which i need in my test cases.
the problem i am facing is i dont want to call the class TestDBMethods.java in each and every test case as this is very expensive. so i prefer to include a singleton class which calls TestDBMethods.java only once and returns an instance that should be made use by all the other test cases. Could anyone please help me in writing code for the singleton class which calls the class TestDBMethods.java and return an instance.