I am using AWS CodeBuild to run unit tests for my python project using pytest. I am using the --junitxml argument and the pytest-cov package to generate test reports and coverage reports that I've listed as artifacts in my buildspec.yml.
I've used Jenkins in the past to do this and Jenkins provides some nice graphs and tables showing test result history and coverage history as well as results from the most recent test.
Is there a good way to view the reports generated by my CodeBuild project? I haven't found anything in CodeBuild or CodePipeline directly. Do I have to use a separate tool that can ingest the report files? If so, what are some tools for this?
Code coverage option is available under the Test menu when you run test methods using Test Explorer. The results table shows the percentage of the code executed in each assembly, class, and procedure. The source editor highlights the tested code.
AWS CodeBuild announced the launch of a new feature in CodeBuild called Reports. This feature allows you to view the reports generated by functional or integration tests. The reports can be in the JUnit XML or Cucumber JSON format.
To see the entire build log in CloudWatch Logs, choose the View entire log link. In the CloudWatch Logs log stream, you can browse the log events. By default, only the last set of log events is displayed. To see earlier log events, scroll to the beginning of the list.
A buildspec is a collection of build commands and related settings, in YAML format, that CodeBuild uses to run a build. Without a build spec, CodeBuild cannot successfully convert your build input into build output or locate the build output artifact in the build environment to upload to your output bucket.
CodeBuild recently announced support for test reports. Copied from the blog post:
The reports can be in the JUnit XML or Cucumber JSON format. You can view metrics such as Pass Rate %, Test Run Duration, and number of Passed versus Failed/Error test cases in one location. Builders can use any testing frameworks as long as the reports are generated in the supported formats.
Two things needs to be updated to accomplish this. First, add some configuration to the buildspec.yml
file:
reports:
SurefireReports: # CodeBuild will create a report group called "SurefireReports".
files: #Store all of the files
- '**/*'
base-directory: 'target/surefire-reports' # Location of the reports
Secondly, CodeBuild needs some additional IAM permissions:
{
"Statement": [
{
"Resource": "arn:aws:codebuild:your-region:your-aws-account-id:report-group/my-project-*",
"Effect": "Allow",
"Action": [
"codebuild:CreateReportGroup",
"codebuild:CreateReport",
"codebuild:UpdateReport",
"codebuild:BatchPutTestCases"
]
}
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With