Why JUnit report is not created in Pipeline

Hi,

Could someone help me on this? Why no xml report is generated from this Pipeline Script?

pipeline{  
    agent any
    stages{  
      stage('Checkout'){  
        steps{  
          checkout scmGit(branches:[[name:'*/main']],
          extensions:[],userRemoteConfigs:[[url:'https://github.com/raul-parada/Python-Selenium.git']])}}  
      stage('Build'){  
        steps{  
          git branch: 'main', url:'https://github.com/raul-parada/Python-Selenium.git'  
          sh 'python3 test_*.py'}}  
      stage('Test'){  
        steps{  
          sh 'python3 -m pytest'}}          
      stage('Publish junit report'){  
        steps{  
          junit allowEmptyResults:true,testResults: 
          '**/*.xml',skipPublishingChecks:true,
          skipMarkingBuildUnstable:true}}}}

Is it located in a given place?

  1. Python-Selenium/result.xml at e81bf852810716969c05651ea7a98f73ef15f40b · raul-parada/Python-Selenium · GitHub is empty
  2. why are you calling sh 'python3 test_*.py' and python3 -m pytest don’t they do the same thing?
  3. I believe you need to tell it to created an xml file, so python3 -m pytest --junitxml=junit.xml or something?

I have modified the Build stage as:

stage('Build'){  
        steps{  
          git branch: 'main', url:'https://github.com/raul-parada/Python-Selenium.git'  
          sh 'python3 test_*.py --junitxml=junit.xml'}}

However, nothing is created. Where should it be located?

–junitxml isn’t a parameter for python, its a parameter for pytest

I think you should figure out how to generate the junit xml without jenkins before trying to get jenkins to do it.

So, there is not any way to generate a simple test report from Jenkins?

It can’t create something from nothing.

Junit is a pretty universally accepted standard. I’ve never encountered a testing framework that can’t produce a junit XML file.

Then you feed that junit results file info Jenkins and get a nice pretty report.

But you need to produce the junit data like I suggested earlier

You might try the Python tutorial. It includes a test execution and test results display.