- Notifications
You must be signed in to change notification settings - Fork1
UnitTestBot/UTBotJava-action
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
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 theUTBotJava 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 theUTBot 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-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
- Check the Security Code Scanning Alerts to see the detected errors.
Here are the input data parameters for the UTBotJava-action:
Name | Description | Options | Default value |
---|---|---|---|
pushTests | Push generated tests to the repository or not | - | true |
targetClasses | Classes for which the SARIF report will be created | - | all |
generatedTestsRelativeRoot | Relative path (against repository root) to the root of the generated tests. | - | .utbot/test |
testFramework | The name of the test framework to be used | junit4, junit5, testng | junit5 |
generationTimeout | Time budget for generating tests for one class (in milliseconds) | - | 60000 |
codegenLanguage | The language of the generated tests | java, kotlin | java |
mockStrategy | The mock strategy to be used | no-mocks, other-packages, other-classes | other-packages |
staticsMocking | Use static methods mocking or not | do-not-mock-statics, mock-statics | mock-statics |
forceStaticMocking | Forces mocking static methods and constructors for classesToMockAlways classes or not | force, do-not-force. | force |
classesToMockAlways | Classes 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]'
Apart from the automatic action, you can also create a workflow with aRun workflow button that will let you launch the action manually. Like this:
How to do this? Find a step-by-step instruction in theexample repository. 😉
About
An action for unit tests generation and SARIF report creation with the UTBotJava engine
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.