diff --git a/.github/workflows/foresight.yml b/.github/workflows/foresight.yml index a243e2570..11931106c 100644 --- a/.github/workflows/foresight.yml +++ b/.github/workflows/foresight.yml @@ -6,8 +6,14 @@ 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: @@ -15,6 +21,7 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Collect Workflow Telemetry if: always() uses: runforesight/foresight-workflow-kit-action@v1 @@ -29,13 +36,13 @@ jobs: 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: jacoco/xml + coverage_path: "**/target/site/jacoco/*.xml" diff --git a/README.md b/README.md index 9e2c3aebb..076127a1d 100644 --- a/README.md +++ b/README.md @@ -1,55 +1,19 @@ -[![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. - -## Documentation +## runforesight.com Demo Projects - Junit Quickcheck -[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.*; - - @RunWith(JUnitQuickcheck.class) - public class StringProperties { - @Property public void concatenationLength(String s1, String s2) { - assertEquals(s1.length() + s2.length(), (s1 + s2).length()); - } - } -``` - -## Other examples + + see it on foresight + -After browsing the [documentation](#documentation), have a look at some -[examples](examples) in module `junit-quickcheck-examples`. These are built -with junit-quickcheck. +--- +![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) + +| Report Attribute | Value | +|---|---| +| Language | Java | +| Test Framework | Junit | +| Test Report Format | JUnit | +| Coverage Format | Jacoco / XML | +| Coverage Format 2 | Cobertura / XML | diff --git a/core/src/main/java/com/pholser/junit/quickcheck/internal/FakeAnnotatedTypeFactory.java b/core/src/main/java/com/pholser/junit/quickcheck/internal/FakeAnnotatedTypeFactory.java index 67f5ac715..9fabd8577 100644 --- a/core/src/main/java/com/pholser/junit/quickcheck/internal/FakeAnnotatedTypeFactory.java +++ b/core/src/main/java/com/pholser/junit/quickcheck/internal/FakeAnnotatedTypeFactory.java @@ -47,6 +47,25 @@ private static AnnotatedType makePlainType(Class type) { return new FakeAnnotatedType(type); } + private static void testUpdate(int v) { + if(v > 0) { + System.out.println("v > 0"); + } + else if(v < 0) { + System.out.println("v < 0"); + } + else { + System.out.println("v == 0"); + } + } + + private static int testDemo(int x, int y) { + int sum = x+y; + int div = y != 0 ? x/y : 1; + + return sum * sum + div * div; + } + private static final class FakeAnnotatedArrayType implements AnnotatedArrayType {