Install
proptastic is a library your tests call, so adding it is one test dependency. There’s no runner of its own to set up: your test framework runs the properties, and your build tool reports their failures as it reports any other.
What you need
Section titled “What you need”- JDK 17 or later.
- Gradle or Maven.
- A test framework: JUnit 5, JUnit 4, TestNG, Kotest or Spock, or Kotlin’s tests on JUnit 5. With your test framework shows the setup for each, and how a failure looks in it.
Add the dependency
Section titled “Add the dependency”import org.gradle.api.tasks.testing.logging.TestExceptionFormat
plugins { java}
repositories { mavenCentral()}
dependencies { testImplementation("io.proptastic:proptastic:1.0.0") testImplementation(platform("org.junit:junit-bom:5.12.2")) testImplementation("org.junit.jupiter:junit-jupiter") testRuntimeOnly("org.junit.platform:junit-platform-launcher")}
tasks.test { useJUnitPlatform() testLogging { exceptionFormat = TestExceptionFormat.FULL showStackTraces = false }}Gradle prints only the type of a failed test’s exception unless told otherwise, and
proptastic’s report is in its message, so exceptionFormat = FULL shows it. showStackTraces = false keeps the output to the message and its cause.
To assert with AssertJ, as the Quickstart’s AssertJ tabs do, add it beside JUnit:
testImplementation("org.assertj:assertj-core:3.27.3")<dependency> <groupId>io.proptastic</groupId> <artifactId>proptastic</artifactId> <version>1.0.0</version> <scope>test</scope></dependency><dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter</artifactId> <version>5.12.2</version> <scope>test</scope></dependency>Maven finds it on Maven Central with no setting of its own. Surefire runs the classes whose names start with Test or end with Test,
Tests or TestCase. Properties in a class named some other way, such as SortProperties, need
an <include> in Surefire’s configuration.
To assert with AssertJ, as the Quickstart’s AssertJ tabs do, add it beside JUnit:
<dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> <version>3.27.3</version> <scope>test</scope></dependency>In Kotlin
Section titled “In Kotlin”The library is Java and needs no Kotlin. Kotlin’s own ways in, such as .with(…) naming a data
class’s property, are in a jar of their own, on Maven Central beside the library:
dependencies { testImplementation("io.proptastic:proptastic-kotlin:1.0.0")}It brings the library with it, and Kotlin’s standard library, which a Kotlin project has already.
The build plugins
Section titled “The build plugins”Your build runs your properties without anything else. The jobs around them, making a setting
reach the tests, searching for longer, keeping a counterexample once you say so, are proptastic’s
commands, and a Java project runs them from its own build, with nothing else to install: the
Gradle plugin io.proptastic and the Maven plugin io.proptastic:proptastic-maven-plugin, at the
library’s version, both on Maven Central. Build plugins shows both, and
how each command is spelled there.
plugins { java id("io.proptastic") version "1.0.0"}Then ./gradlew proptasticRun runs the properties and summarises them.
<plugin><groupId>io.proptastic</groupId><artifactId>proptastic-maven-plugin</artifactId><version>1.0.0</version><extensions>true</extensions></plugin>Then ./mvnw proptastic:run runs the properties and summarises them.
The command
Section titled “The command”For a build that isn’t Java’s, or to run the commands outside a build, there’s the proptastic
command. Your build runs your properties without anything else. The proptastic command runs them through
that same build and does the jobs around them: making a setting reach the tests, searching for
longer, and keeping a counterexample once you say so (proptastic run). It
needs nothing installed beside it: the build fetches the library, at the version your project
names.
curl -fsSL https://proptastic.io/install.sh | shThat installs the latest release for this machine: macOS on Apple silicon or Intel, or Linux on
x86-64 or Arm64. The Linux builds are static, so one archive runs on any distribution. It needs
curl and tar.
It checks the download against the release’s SHA256SUMS, and refuses one that doesn’t match. It
keeps the release in ~/.proptastic/native-<version> and links proptastic into ~/.local/bin.
If ~/.local/bin isn’t on your PATH, it prints the line to add for your shell. It writes nowhere
else, so removing those two directories uninstalls it.
In PowerShell, 5.1 or 7:
irm https://proptastic.io/install.ps1 | iexThat installs the latest release for Windows on x64 or Arm64. It checks the download against the
release’s SHA256SUMS, keeps it in %USERPROFILE%\.proptastic\native-<version>, copies
proptastic.exe into %USERPROFILE%\.proptastic\bin, and adds that folder to your user Path,
so every terminal you open from then on finds it. To uninstall, delete
%USERPROFILE%\.proptastic, and take its bin folder out of your user Path.
In Git Bash, MSYS2 or Cygwin, the curl line installs the same release into the same folders.
Run it again to update. These variables change what it does, named as mutastic’s installer names its own:
| Variable | Effect |
|---|---|
PROPTASTIC_NATIVE_VERSION |
The release to install, such as 0.1.0: the latest unless set |
PROPTASTIC_HOME |
Where releases are kept: ~/.proptastic unless set |
PROPTASTIC_BIN_DIR |
Where the command goes: ~/.local/bin unless set, or on Windows the bin folder in PROPTASTIC_HOME |
PROPTASTIC_NATIVE_RELEASES |
Where releases are downloaded from, for a mirror: GitHub’s releases of proptastic/proptastic-rs unless set |
Build it from a clone
Section titled “Build it from a clone”To try a change before it’s released, build proptastic from a clone and install it in your local Maven repository:
git clone https://github.com/proptastic/proptastic.gitcd proptasticjust installjust install builds the jar and puts it in ~/.m2/repository, with the one library it needs,
opentest4j, for its failure type, and the Kotlin jar and the
agent beside it. Without just, run sh scripts/install.sh,
which is what the recipe runs. The build downloads the JDKs it needs, so all it asks of your
machine is a JDK to start Gradle with. Maven looks in your local repository first; under Gradle,
add mavenLocal() above mavenCentral() in repositories.
Quickstart: write a property, watch it fail, and pin the input it found, in five minutes.