Skip to content

Commit f6434ed

Browse files
author
Ferenc Hammerl
committed
Add integration test for listing all polls
1 parent 46c1992 commit f6434ed

File tree

3 files changed

+45
-13
lines changed

3 files changed

+45
-13
lines changed

pom.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@
3939
<artifactId>postgresql</artifactId>
4040
<scope>runtime</scope>
4141
</dependency>
42+
43+
<dependency>
44+
<groupId>org.junit.jupiter</groupId>
45+
<artifactId>junit-jupiter-api</artifactId>
46+
<version>5.7.0</version>
47+
<scope>test</scope>
48+
</dependency>
49+
<dependency>
50+
<groupId>org.junit.jupiter</groupId>
51+
<artifactId>junit-jupiter-engine</artifactId>
52+
<version>5.7.0</version>
53+
<scope>test</scope>
54+
</dependency>
4255
</dependencies>
4356

4457
<build>

src/test/java/com/fhammerl/polls/PollsApplicationTests.java

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.fhammerl.polls;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
5+
import java.util.List;
6+
7+
import com.fhammerl.polls.models.Poll;
8+
9+
import org.junit.jupiter.api.Test;
10+
import org.springframework.beans.factory.annotation.Autowired;
11+
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
12+
import org.springframework.boot.test.context.SpringBootTest;
13+
14+
import com.fhammerl.polls.controllers.PollsController;
15+
/*
16+
These tests are all dpeendent on the DB being set up properly
17+
They are at best smoke test
18+
*/
19+
20+
@SpringBootTest
21+
@AutoConfigureMockMvc
22+
class PollsControllerTests {
23+
24+
@Autowired
25+
private PollsController pollsController;
26+
27+
@Test
28+
void listAllWorks() throws Exception {
29+
List<Poll> polls = pollsController.list();
30+
assertEquals(polls.toArray().length, 2, "Unexpected number of polls found!");
31+
}
32+
}

0 commit comments

Comments
 (0)