How to configure Gitlab CI to parse test output?

1.5k views Asked by At

I am working on Gitlab and I would like to set up a CI (it is the first time I configure something like that, please assume that I am a beginner)

I wrote a code in C with a simple test in Cunit, I configured CI with a "build" job and a "test" job. My test job succeed whereas I wrote a KO test, when I open the job on Gitlab I see the failed output, but the job is marked "Passed".

How can I configure Gitlab to understand that the test failed ?

I think there is a parsing configuration somewhere, I tried in "CI / CD Setting -> Test coverage parsing" but I think it is wrong, and it did not work.

I let you the output of my test :

     CUnit - A unit testing framework for C - Version 2.1-2
     http://cunit.sourceforge.net/


Suite: TEST SUITE FUNCTION
  Test: Test of function::triple ...FAILED
    1. main.c:61  - CU_ASSERT_EQUAL(triple(3),1)

Run Summary:    Type  Total    Ran Passed Failed Inactive<br/>
              suites      1      1    n/a      0        0<br/>
               tests      1      1      0      1        0<br/>
             asserts      3      3      2      1      n/a<br/>

Elapsed time =    0.000 seconds
1

There are 1 answers

0
Efren On

Gitlab supports test reports in JUnit format and coverage reports in cobertura XML format

See the links for C++ examples that may help you, as an example for CUnit, the .gitlab_ci.yaml file should look like:

cunit:
  stage: test
  script:
    - ./my-cunit-test
  artifacts:
    when: always
    reports:
      junit: ./my-cunit-test.xml