diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ced52d4ead3e4f66cadfe23794b1f3f74c65f14a..9f3e710c621f01c0dc2dbf9ac4f35ab9266c86c6 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -5,6 +5,11 @@ stages:
   - packaging
   - test
 
+variables:
+  POSTGRES_DB: map_viewer
+  POSTGRES_USER: map_viewer
+  POSTGRES_PASSWORD: "123qweasdzxc"
+
 test_frontend:
   stage: test
   script:
@@ -13,17 +18,21 @@ test_frontend:
     - npm test
 
 test_backend:
-  variables:
-    POSTGRES_DB: map_viewer
-    POSTGRES_USER: map_viewer
-    POSTGRES_PASSWORD: 123qweasdzxc
-  image: debian
+  image: maven:3.3-jdk-8
   services:
     - postgres:latest
   stage: test
   script:
     - apt-get update
-    - apt-get install -y openjdk-8-jdk maven
+    - apt-get install -y xvfb
+#xvfb is for X11 connection used by some parts of the java code: https://stackoverflow.com/a/47575851/1127920
+    - Xvfb :99 &
+    - export DISPLAY=:99
+#connection to the db
+    - mkdir /etc/minerva/
+    - echo "database.uri=jdbc:postgresql://$POSTGRES_PORT_5432_TCP_ADDR:5432/map_viewer" >>/etc/minerva/test-db.properties
+    - echo "database.username=map_viewer" >>/etc/minerva/test-db.properties
+    - echo "database.password=123qweasdzxc">>/etc/minerva/test-db.properties
     - mvn test
 
 build_war: