Skip to content
Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

14 Commits

Repository files navigation

UTBotJava-action

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! 😃

How to use

  1. Start with applying the UTBot gradle plugin to your project.
  2. Then, create the workflow with UTBotJava-action. Simple workflow example:
name: "Run UTBotJava-action"on: [push]jobs:
build:
runs-on: ubuntu-lateststeps:
- name: Checkoutuses: actions/checkout@v2
- name: Setup Javauses: actions/setup-java@v2with:
distribution: adoptjava-version: 8
- name: Setup Gradleuses: gradle/gradle-build-action@v2with:
gradle-version: 6.8
- name: Run UTBotJava-actionuses: UnitTestBot/UTBotJava-action@v1
  1. Check the Security Code Scanning Alerts to see the detected errors.

Inputs

Here are the input data parameters for the UTBotJava-action:

NameDescriptionOptionsDefault value
pushTestsPush generated tests to the repository or not-true
targetClassesClasses for which the SARIF report will be created-all
generatedTestsRelativeRootRelative path (against repository root) to the root of the generated tests.-.utbot/test
testFrameworkThe name of the test framework to be usedjunit4, junit5, testngjunit5
generationTimeoutTime budget for generating tests for one class (in milliseconds)-60000
codegenLanguageThe language of the generated testsjava, kotlinjava
mockStrategyThe mock strategy to be usedno-mocks, other-packages, other-classesother-packages
staticsMockingUse static methods mocking or notdo-not-mock-statics, mock-staticsmock-statics
forceStaticMockingForces mocking static methods and constructors for classesToMockAlways classes or notforce, do-not-force.force
classesToMockAlwaysClasses to force mocking theirs static methods and constructors-some internal classes

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-lateststeps:
- name: Checkoutuses: actions/checkout@v2with:
# required if you want to push generated tests in your pull requestref: ${{ github.head_ref }}
- name: Setup Javauses: actions/setup-java@v2with:
distribution: adoptjava-version: 8
- name: Setup Gradleuses: gradle/gradle-build-action@v2with:
gradle-version: 6.8
- name: Run UTBotJava-actionuses: UnitTestBot/UTBotJava-action@v1with:
pushTests: 'true'targetClasses: '[com.github.username.SomeClass, com.github.username.AnotherClass]'generatedTestsRelativeRoot: 'src/test'testFramework: 'testng'generationTimeout: 50000# mscodegenLanguage: 'kotlin'mockStrategy: 'other-classes'staticsMocking: 'do-not-mock-statics'forceStaticMocking: 'do-not-force'classesToMockAlways: '[java.util.Random]'

Manual trigger configuration

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:

image

How to do this? Find a step-by-step instruction in the example repository. 😉

About

An action for unit tests generation and SARIF report creation with the UTBotJava engine

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors