Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a method #39

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/diffblue-cover.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# This template is provided and maintained by Diffblue.
# You can copy and paste this template into a new `diffblue-cover.yml` file.
# This template is designed to be used with the Cover Pipeline for Github integration from Diffblue.
# It will download the latest version of Diffblue Cover, build the associated project, and
# automatically write Java unit tests for the project.

name: Automated Test Creation with Diffblue Cover

# Diffblue Cover runs on pull_request events for now.
on: pull_request

jobs:
RunDiffblueCoverAutomatedTestCreation:
runs-on: ubuntu-latest

# Select the Cover CLI docker image to use with your CI tool.
# Tag variations are produced for each supported JDK version.
# Go to https://hub.docker.com/r/diffblue/cover-cli for details.
# Note: To use the latest version of Diffblue Cover, use one of the latest-jdk<nn> tags.
# To use a specific release version, use one of the yyyy.mm.dd-jdk<nn> tags
container: diffblue/internal-cover-cli:nightly-jdk17

steps:
- name: Checkout project
uses: actions/checkout@v4
with:
set-safe-directory: true
fetch-depth: 0
# Diffblue Cover requires the project to be built before creating any tests.
# Either specify the build command here (one of the following), or provide
# prebuilt artifacts via a job dependency.
- name: Build Project
run: mvn test-compile --batch-mode --no-transfer-progress

# Diffblue Cover commands and options to run.
# dcover – the core Diffblue Cover command
# ci – enable CI/CD integration via environment variables
# activate - activate the license key
# validate - remove non-compiling and failing tests
# create - create new tests for your project
# --maven – use the maven build tool
# For detailed information on Cover CLI commands and options, see
# https://docs.diffblue.com/features/cover-cli/commands-and-arguments

- name: Run Diffblue Cover
env:
DIFFBLUE_ACCESS_TOKEN: ${{ secrets.DIFFBLUE_TOKEN }}
GITHUB_PR_NUMBER: ${{ github.event.number }}
JVM_ARGS: -Xmx4g
run: |
export GITHUB_REPO_NAME=`echo $GITHUB_REPOSITORY | awk -F'/' '{print $2}'`
git config --global --add safe.directory /__w/$GITHUB_REPO_NAME/$GITHUB_REPO_NAME
dcover ci activate ${{ secrets.DIFFBLUE_LICENSE_KEY }} validate create

#############################################################################
# SPECULATION: If we had a Docker based action then would it look like this?

- name: Run Diffblue Cover
uses: diffblue/[email protected]
with:
license: ${{ secrets.DIFFBLUE_LICENSE }}
token: ${{ secrets.DIFFBLUE_ACCESS_TOKEN }}
commands: validate create

#############################################################################
4 changes: 4 additions & 0 deletions src/main/java/io/diffblue/javademo/TicTacToe.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,8 @@ public int checkTicTacToePosition(int[] board) throws IllegalArgumentException {
// Neither player has won yet
return 0;
}

public int add(int a, int b) throws IllegalArgumentException {
return a+b;
}
}
Loading