STASIS
A pipeline delivery generator
Loading...
Searching...
No Matches
junitxml.h File Reference
#include <libxml/xmlreader.h>
Include dependency graph for junitxml.h:

Go to the source code of this file.

Data Structures

struct  JUNIT_Failure
 
struct  JUNIT_Error
 
struct  JUNIT_Skipped
 
struct  JUNIT_Testcase
 
union  JUNIT_Testcase::tc_state_ptr
 Type container for result (there can only be one) More...
 
struct  JUNIT_Testsuite
 

Macros

#define JUNIT_RESULT_STATE_NONE   0
 
#define JUNIT_RESULT_STATE_FAILURE   1
 
#define JUNIT_RESULT_STATE_SKIPPED   2
 
#define JUNIT_RESULT_STATE_ERROR   3
 

Functions

struct JUNIT_Testsuitejunitxml_testsuite_read (const char *filename)
 
void junitxml_testsuite_free (struct JUNIT_Testsuite **testsuite)
 

Function Documentation

◆ junitxml_testsuite_free()

void junitxml_testsuite_free ( struct JUNIT_Testsuite ** testsuite)

Free memory allocated by junitxml_testsuite_read

Parameters
testsuitepointer to JUNIT_Testsuite

◆ junitxml_testsuite_read()

struct JUNIT_Testsuite * junitxml_testsuite_read ( const char * filename)

Extract information from a junit XML file

struct JUNIT_Testsuite *testsuite;
const char *filename = "/path/to/result.xml";
testsuite = junitxml_testsuite_read(filename);
if (testsuite) {
// Did any test cases fail?
if (testsuite->failures) {
printf("Test suite '%s' has %d failure(s)\n", testsuite->name, testsuite->failures
// Scan test cases for failure data
for (size_t i = 0; i < testsuite->_tc_inuse; i++) {
// Check result state (one of)
// JUNIT_RESULT_STATE_FAILURE
// JUNIT_RESULT_STATE_ERROR
// JUNIT_RESULT_STATE_SKIPPED
struct JUNIT_Testcase *testcase = testsuite->testcase[i];
if (testcase->tc_result_state_type) {
if (testcase->tc_result_state_type == JUNIT_RESULT_STATE_FAILURE) {
// Display information from failed test case
printf("[FAILED] %s::%s\nOutput:\n%s\n",
testcase->classname,
testcase->name,
testcase->result_state.failure->message);
}
}
}
}
// Release test suite resources
} else {
// handle error
}
void junitxml_testsuite_free(struct JUNIT_Testsuite **testsuite)
Definition junitxml.c:44
struct JUNIT_Testsuite * junitxml_testsuite_read(const char *filename)
Definition junitxml.c:312
char * message
Error text.
Definition junitxml.h:16
Definition junitxml.h:40
char * name
Name of test.
Definition junitxml.h:44
int tc_result_state_type
Result type.
Definition junitxml.h:50
char * classname
Class name.
Definition junitxml.h:42
union JUNIT_Testcase::tc_state_ptr result_state
Result data.
Definition junitxml.h:62
struct JUNIT_Testcase ** testcase
Array of test cases.
Definition junitxml.h:82
char * name
Test suite name.
Definition junitxml.h:64
size_t _tc_inuse
Total number of test cases in use.
Definition junitxml.h:84
int failures
Total number of failed tests.
Definition junitxml.h:68
Parameters
filenamepath to junit XML file
Returns
pointer to JUNIT_Testsuite
Here is the call graph for this function: