I have some requirement that at least 80% of the line coverage need to be achieved. I have some file where a large portion of the code is under if __name__ == '__main__': which need not to be tested.
How can I instruct SonarQube to exclude that portion of code from test coverage. I have seen there are options to exclude files and module using sonar.exclusions and sonar.coverage.exclusions. It would be a great help for me to exclude some parts of a file. For example, I want to exclude everything in the if __name__ == '__main__': block below from sonarQube:
#Test Everything inside this method
def do_something():
# Some code
# Do not test and include the following codes in the SonarQube coverage
if __name__ == '__main__':
# A lot of codes for running different functions of this module