Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Static code analysis with UTBotJava action

Olga Naumenko edited this pageNov 17, 2022 ·1 revision

To analyse the Java project withUTBotJava-action you need to follow these simple steps:

  1. Apply theUTBot gradle plugin to your project:
plugins {    id"org.utbot.gradle.plugin" version"1.0.0-alpha"}
  1. Create a new file<your-repository>/.github/workflows/run-utbot-java-action.yml with a workflow that can be run and configured manually:
name:"Run UTBotJava action"on:workflow_dispatch:inputs:pushTests:description:"Push generated tests to the repository"type:booleandefault:truegeneratedTestsRelativeRoot:description:"Relative path to the root of the tests"type:stringdefault:'.utbot/test'testFramework:type:choiceoptions:          -junit4          -junit5          -testngdefault:'junit5'generationTimeout:description:"Time budget for one class (ms)"type:stringdefault:'60000'codegenLanguage:type:choiceoptions:          -java          -kotlindefault:javamockStrategy:type:choiceoptions:          -'no-mocks'          -'other-packages'          -'other-classes'default:'other-packages'staticsMocking:type:choiceoptions:           -'do-not-mock-statics'          -'mock-statics'default:'mock-statics'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@v1with:pushTests:${{ inputs.pushTests }}generatedTestsRelativeRoot:${{ inputs.generatedTestsRelativeRoot }}testFramework:${{ inputs.testFramework }}generationTimeout:${{ inputs.generationTimeout }}codegenLanguage:${{ inputs.codegenLanguage }}mockStrategy:${{ inputs.mockStrategy }}staticsMocking:${{ inputs.staticsMocking }}
  1. On theActions tab find the sectionRun UTBotJava action:

image

  1. ClickRun workflow and select the needed options:

image

  1. After the workflow is completed, look at theSecurity → Code Scanning Alerts to find the detected errors (by the way, you won`t find any if your code is fine 😉):

image

  1. Explore any alert by clicking on it:

image

As you see in this case above, UTBot detected an unchecked ArrayIndexOutOfBoundsException by passing the array[-192, -192] to theisSorted method.

ClickShow paths button, and you see the execution trace.

📍Note: You can find all these steps performed in our sample project:UTBotJava-action-example

User guides

IntelliJ IDEA plugin

Contributor guides

(redirect to/docs inmain repo)

General info

Continuous integration

Design docs

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp