This is a simple Python project with some test cases. I connected it to SonarQube to get me the code coverage of the repository. So far it's only telling me python files code coverage
You need to install sonarQube thing from the video in the beginning. Also need Docker
To run the main program:
I followed this video mainly to get SonarQube active (https://youtu.be/6vdRvz_LnbQ)
First I made sure docker was running then ran the commands, docker pull sonarqube
and docker run -d --name sonarqube-db -e POSTGRES_USER=sonar -e POSTGRES_PASSWORD=sonar -e POSTGRES_DB=sonarqube postgres:alpine
Also the command docker run -d --name sonarqube -p 9000:9000 --link sonarqube-db:db -e SONAR_JDBC_URL=jdbc:postgresql://db:5432/sonarqube -e SONAR_JDBC_USERNAME=sonar -e SONAR_JDBC_PASSWORD=sonar sonarqube
Then I ran pytest --cov=. --cov-report=xml to get an xml report of the python test cases.
I am not sure why I had to do this. I thought SonarQube would be able to do it for me.
Also in sonar-scanner.properties I added in an exclusion line to exclude test_main.py from it
Next I ran /Users/eleanorfoley/Documents/WPI/MQP/sonar-scanner-6.2.1.4610-macosx-aarch64/bin/sonar-scanner \ -Dsonar.projectKey=week1test \ -Dsonar.sources=. \ -Dsonar.host.url=http://localhost:9000 \ -Dsonar.token=sqp_847fbaa192f7c87a62d5afe7df0b74832385f7dd
This was the last step
Afterwards can go in docker and run them
#Seperate
Interesting command is pytest --cov=. --cov-report=term-missing