Is there a way to use an extra test database for my java tests using intellj?

Viewed 56

I am trying to use an extra test database for my java tests.

I´m using Maven as Build-Management-Tool. As testing FrameWork Junit (Junit 5).

In the test folder in Intellj, I have created an extra resources folder and hibernate.cfg.xml. The connection to the test database is stored in this cfg file:

    <!-- Database connection settings -->
    <property name="connection.url">jdbc:mysql://localhost:3306/test_database</property>
    <property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property>
    <property name="connection.username">root</property>
    <property name="connection.password"> </property>

    <!-- SQL dialect -->
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>

    <!-- Echo all executed SQL to stdout -->
    <property name="show_sql">false</property>
    <property name="format_sql">true</property>
    <property name="current_session_context_class">thread</property>

    <!-- Mapping Entity classes -->
    <mapping class="entity.UserEntity"/>

Does anyone have experience how to use an extra database for testing? Is there anything I need to consider when using Intellj?

Do you even separate a development database and a test database for testing? Or do you just use one database?

I am still a newbie when it comes to javatests.

If you need more information, let me know.

0 Answers
Related