diff --git a/.github/workflows/foresight.yml b/.github/workflows/foresight.yml index a243e2570..ea7e20e50 100644 --- a/.github/workflows/foresight.yml +++ b/.github/workflows/foresight.yml @@ -6,7 +6,12 @@ on: pull_request: branches: [ "master" ] workflow_dispatch: + schedule: + - cron: "0 1 * * *" +env: + FORESIGHT_UPLOADER_SIGNER_URL: https://upload.service.runforesight.us + WORKFLOW_TELEMETRY_BASE_URL: https://api.service.runforesight.us jobs: build: @@ -21,21 +26,20 @@ jobs: with: api_key: ${{ secrets.FORESIGHT_API_KEY }} - - name: Set up JDK 11 + - name: Set up JDK 8 uses: actions/setup-java@v3 with: - java-version: '11' + java-version: '8' distribution: 'temurin' cache: maven - - name: Build with Maven - run: mvn clean install + run: mvn clean -fn install - name: Analyze Test and/or Coverage Results if: always() - uses: thundra-io/foresight-test-kit-action@v1 + uses: runforesight/foresight-test-kit-action@v1 with: api_key: ${{ secrets.FORESIGHT_API_KEY }} - test_framework: junit - test_path: "**/target/surefire-reports/**" + coverage_format: cobertura/xml + coverage_path: "**/target/site/cobertura/*.xml" diff --git a/README.md b/README.md index 9e2c3aebb..06f971240 100644 --- a/README.md +++ b/README.md @@ -1,55 +1,20 @@ -[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.pholser/property-binder/badge.svg?style=plastic)](https://maven-badges.herokuapp.com/maven-central/com.pholser/junit-quickcheck) -[![Build Status](https://travis-ci.org/pholser/junit-quickcheck.svg?branch=master)](https://travis-ci.org/pholser/junit-quickcheck) -[![Code Quality: Java](https://img.shields.io/lgtm/grade/java/g/pholser/junit-quickcheck.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/pholser/junit-quickcheck/context:java) -[![Total Alerts](https://img.shields.io/lgtm/alerts/g/pholser/junit-quickcheck.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/pholser/junit-quickcheck/alerts) - - Software Quality Award 2016 - - -# junit-quickcheck: Property-based testing, JUnit-style - -junit-quickcheck is a library that supports writing and running property-based -tests in JUnit, inspired by QuickCheck for Haskell. - -Property-based tests capture characteristics, or "properties", of the output -of code that should be true given arbitrary inputs that meet certain criteria. -For example, imagine a function that produces a list of the prime factors of -a positive integer `n` greater than 1. Regardless of the specific value of -`n`, the function must give a list whose members are all primes, must -equal `n` when all multiplied together, and must be different from the -factorization of a positive integer `m` greater than 1 and not equal to -`n`. - -Rather than testing such properties for all possible inputs, junit-quickcheck -and other QuickCheck kin generate some number of random inputs, and verify -that the properties hold at least for the generated inputs. This gives us -some reasonable assurance upon repeated test runs that the properties -hold true for any valid inputs. +## runforesight.com Demo Projects - Junit Quickcheck -## Documentation - -[Documentation for the current stable version](https://pholser.github.io/junit-quickcheck/index.html) - -## Basic example - -```java - import com.pholser.junit.quickcheck.Property; - import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; - import org.junit.runner.RunWith; - - import static org.junit.Assert.*; + + see it on foresight + - @RunWith(JUnitQuickcheck.class) - public class StringProperties { - @Property public void concatenationLength(String s1, String s2) { - assertEquals(s1.length() + s2.length(), (s1 + s2).length()); - } - } -``` +--- +![Success Details](https://api-public.service.runforesight.com/api/v1/badge/success?repoId=5c43d0bb-71db-429f-a5b5-ebf7d5622aef) +![Test Result](https://api-public.service.runforesight.com/api/v1/badge/test?repoId=5c43d0bb-71db-429f-a5b5-ebf7d5622aef) +![Utilization](https://api-public.service.runforesight.com/api/v1/badge/utilization?repoId=5c43d0bb-71db-429f-a5b5-ebf7d5622aef) -## Other examples -After browsing the [documentation](#documentation), have a look at some -[examples](examples) in module `junit-quickcheck-examples`. These are built -with junit-quickcheck. +| Report Attribute | Value | +|---|---| +| Language | Java | +| Test Framework | Junit | +| Test Report Format | JUnit | +| Coverage Format | Jacoco / XML | +| Coverage Format 2 | Cobertura / XML | diff --git a/guava/src/main/java/com/pholser/junit/quickcheck/guava/generator/OptionalGenerator.java b/guava/src/main/java/com/pholser/junit/quickcheck/guava/generator/OptionalGenerator.java index 9d05f3929..5ef8b40b4 100644 --- a/guava/src/main/java/com/pholser/junit/quickcheck/guava/generator/OptionalGenerator.java +++ b/guava/src/main/java/com/pholser/junit/quickcheck/guava/generator/OptionalGenerator.java @@ -36,6 +36,8 @@ a copy of this software and associated documentation files (the import java.util.ArrayList; import java.util.List; +import java.util.Arrays; + /** * Produces values of type {@link Optional}. */ @@ -85,4 +87,11 @@ public OptionalGenerator() { .map(componentGenerators().get(0)::magnitude) .orElse(ZERO); } + private void sum() { + int a[] = {2, 6, 1, 4}; + int b[] = {2, 1, 4, 4}; + + int result[] = new int[a.length]; + Arrays.setAll(result, i -> a[i] + b[i]); + } } diff --git a/pom.xml b/pom.xml index db7e26025..c39666ae9 100644 --- a/pom.xml +++ b/pom.xml @@ -371,6 +371,35 @@ + + org.codehaus.mojo + cobertura-maven-plugin + 2.7 + + + 0 + 0 + true + 0 + 0 + 0 + 0 + + + xml + + true + + + + post-integration-test + + check + cobertura + + + + org.apache.maven.plugins maven-source-plugin @@ -409,28 +438,17 @@ - org.apache.maven.plugins - maven-project-info-reports-plugin - - - org.apache.maven.plugins - maven-javadoc-plugin + org.codehaus.mojo + cobertura-maven-plugin + 2.7 - default - javadoc + cobertura - - - org.jacoco - jacoco-maven-plugin - - - org.apache.maven.plugins - maven-pmd-plugin + @@ -449,6 +467,7 @@ + github-pages-site