You want to reduce extra moves and save some time in your working process. We have an action for that!
See: now you can initiate unit tests generation and SARIF report creation right into GitHub with the UTBotJava engine.
The action imports the SARIF output into your GitHub repository and creates the Security Code Scanning Alerts section, where you can find all code errors displayed.
Sounds pretty cool, and it really is! 😃
- Start with applying the UTBot gradle plugin to your project.
- Then, create the workflow with UTBotJava-action. Simple workflow example:
name: "Run UTBotJava-action"
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Java
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 8
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: 6.8
- name: Run UTBotJava-action
uses: UnitTestBot/UTBotJava-action@v1- Check the Security Code Scanning Alerts to see the detected errors.
Here are the input data parameters for the UTBotJava-action:
Workflow example:
📍 Important note: in this case, GitHub displays errors in the Pull Request Checks section.
name: "Run UTBotJava-action"
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# required if you want to push generated tests in your pull request
ref: ${{ github.head_ref }}
- name: Setup Java
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 8
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: 6.8
- name: Run UTBotJava-action
uses: UnitTestBot/UTBotJava-action@v1
with:
pushTests: 'true'
targetClasses: '[com.github.username.SomeClass, com.github.username.AnotherClass]'
generatedTestsRelativeRoot: 'src/test'
testFramework: 'testng'
generationTimeout: 50000 # ms
codegenLanguage: 'kotlin'
mockStrategy: 'other-classes'
staticsMocking: 'do-not-mock-statics'
forceStaticMocking: 'do-not-force'
classesToMockAlways: '[java.util.Random]'Apart from the automatic action, you can also create a workflow with a Run workflow button that will let you launch the action manually. Like this:
How to do this? Find a step-by-step instruction in the example repository. 😉

