Skip to content

Commit

Permalink
- Fixed HibernateDAOTests not running when using "mvn test" (Thanks t…
Browse files Browse the repository at this point in the history
…o dan1st from discordjug.net!)

- Made the dao field static in HibernateDAOTests to let JUnit instantiate it only once, instead of before every test
  • Loading branch information
Eukon05 committed Oct 21, 2024
1 parent 27e9876 commit 50226ba
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
20 changes: 20 additions & 0 deletions infodb-persistence-hibernate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,26 @@
<version>2.3.232</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<version>4.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.1</version>

<configuration>
<argLine>--add-reads org.jboss.logging=java.logging</argLine>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import static org.junit.jupiter.api.Assertions.*;

class HibernateDAOTests {
private final ArticleDAO dao = ServiceLoader.load(ArticleDAO.class).iterator().next();
private static ArticleDAO dao;
private static final String TEST_ORIGIN = "TEST";
private static final String TEST_URL = "https://test.com/%s";
private static final String TEST_IMG_URL = "https://test.com/%s/image.png";
Expand All @@ -24,6 +24,8 @@ static void init() {
p.setProperty("DB_URL", "jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1");
p.setProperty("DB_USER", "sa");
p.setProperty("DB_PASS", "");

dao = ServiceLoader.load(ArticleDAO.class).iterator().next();
}

@Test
Expand Down

0 comments on commit 50226ba

Please sign in to comment.