Running unit tests for code coverage

Hi I am having a bitbucket pipeline to deploy code from a repository containing only python code to sonarcloud for analysis but I also want to run unittests and generate report on it currently all my testscripts are in a folder with the formate test_<file_name>.py and I want to run all of them and generate a report for the same in sonarcloud :
image: python:3.8 # Choose an image matching your project needs
options:
docker: true
size: 2x
clone:
depth: full

definitions:
services:
docker:
memory: 4096
caches:
sonar: ~/.sonar/cache
steps:
- step: &build-test-sonarcloud
name: Build, test and analyze on SonarCloud
caches:
- pip
- sonar
script:
- python3 -m unittest ./folder/tests/*.py
- pipe: sonarsource/sonarcloud-scan:1.2.0

- step: &check-quality-gate-sonarcloud
    name: Check the Quality Gate on SonarCloud
    script:
      - pipe: sonarsource/sonarcloud-quality-gate:0.1.4

pipelines:
branches:
feature/*:
- step: *build-test-sonarcloud
- step: *check-quality-gate-sonarcloud
pull-requests:
“**”:
- step: *build-test-sonarcloud
- step: *check-quality-gate-sonarcloud

here is my pipeline code can you please suggest how to run all the unittest as one batch

Hello @Ali_Hussaini, could you please have a look into this topic? It covers how to generate required files in order to SonarCloud have proper information to evaluate tests results and code coverage. Also check our documentation that shows how to point to those files.

Don’t hesitate to contact us if you need more help and/or information.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.