DB connection between classes
Thursday, 30 August 2018 · 2 messages
KM
Karina C. Malavazi30 Aug 2018 01:21 #
Hello,
I'm new on Java programming and also on nonSQL database... hope you can give me some support.
I have a group of testcases where every time that a test is executed the database has to be connected again, which lets my tests very slow.
Example:
public class AllTests { .
public static Test suite() throws IOException {
TestSuite suite = new TestSuite();
suite.addTestSuite(NumberTest.class);
suite.addTestSuite(LetterTest.class);
suite.addTestSuite(ImageTest.class);
...
}
}In the example above, NumberTest.class, LetterTest.class and ImageTest.class are tests made for some interfaces that use the same document from the database. However, each one of them finish (NumberTest and LetterTest), I have to connect to the database again.
I'm not "closing" it in any place, only opening.
So, why is this being closed every time that a new test is executed?
Is there any way to keep the db connection opened during all the tests and close it only in the end?
Any idea or tip will be helpful.
Thanks,
Karina.
CG
Christian Grün30 Aug 2018 09:31 #
Dear Karina,
Thanks to for mail.
It’s difficult to guess what might happen in your test cases. How do you access BaseX? How do you open a BaseX?
Best,
Christian
Quoted text · Karina C. Malavazi · 38 lines
On Wed, Aug 29, 2018 at 11:21 PM Karina C. Malavazi <929346 at gmail.com> wrote: > > > Hello, > > I'm new on Java programming and also on nonSQL database... hope you can give me some support. > > I have a group of testcases where every time that a test is executed the database has to be connected again, which lets my tests very slow. > > Example: > > public class AllTests { > > . > public static Test suite() throws IOException { > > TestSuite suite = new TestSuite(); > > suite.addTestSuite(NumberTest.class); > suite.addTestSuite(LetterTest.class); > suite.addTestSuite(ImageTest.class); > ... > } > } > > In the example above, NumberTest.class, LetterTest.class and ImageTest.class are tests made for some interfaces that use the same document from the database. However, each one of them finish (NumberTest and LetterTest), I have to connect to the database again. > > I'm not "closing" it in any place, only opening. > > So, why is this being closed every time that a new test is executed? > > Is there any way to keep the db connection opened during all the tests and close it only in the end? > > Any idea or tip will be helpful. > > Thanks, > > Karina.
Written for BaseX 9.0. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery