{"id":25776290,"url":"https://github.com/JetBrains/jetCheck","last_synced_at":"2025-02-27T06:05:58.514Z","repository":{"id":65982604,"uuid":"135719372","full_name":"JetBrains/jetCheck","owner":"JetBrains","description":"Property-based test framework ","archived":false,"fork":false,"pushed_at":"2023-02-01T11:20:04.000Z","size":95,"stargazers_count":80,"open_issues_count":0,"forks_count":6,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-02-15T03:51:16.408Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JetBrains.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-01T13:13:11.000Z","updated_at":"2024-11-23T08:56:40.000Z","dependencies_parsed_at":"2023-02-19T19:30:46.818Z","dependency_job_id":null,"html_url":"https://github.com/JetBrains/jetCheck","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JetBrains%2FjetCheck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JetBrains%2FjetCheck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JetBrains%2FjetCheck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JetBrains%2FjetCheck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JetBrains","download_url":"https://codeload.github.com/JetBrains/jetCheck/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240987435,"owners_count":19889333,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-27T06:01:20.910Z","updated_at":"2025-02-27T06:05:58.507Z","avatar_url":"https://github.com/JetBrains.png","language":"Java","funding_links":[],"categories":["测试"],"sub_categories":[],"readme":"# jetCheck ![Team](https://jb.gg/badges/team-plastic.svg)\n \njetCheck is a property-based testing library for Java 8+, inspired by [QuickCheck](https://en.wikipedia.org/wiki/QuickCheck) and [Hypothesis](https://hypothesis.works/). Its distinguishing features are:\n* Automatic example minimization: you don't need to manually write shrinkers for your custom data types \n* Re-running of minimized test example: once you've got a failing test, you can re-run (and debug) it without all the intermediate shrinking steps\n* Stateful system testing (single-threaded): you can generate a sequence of commands, and each command generation may depend on the state that previous commands have brought the system into.\n\nThe library is by no means supposed to be feature-complete, and might lack even very basic data generators, if no clients have needed them yet. Improvement suggestions are welcome. \n\n# What's property-based testing?\n\n\"Property-based testing\" means that the library checks very general properties that a program should have, as opposed to specific scenarios in unit testing. In *jetCheck*, a number of random test cases are generated, the property is verified on those test cases, and, if it fails, the test case is automatically minimized and printed.\n\nSome examples of properties:\n* For `sort` function, for every input, the output should contain the same elements, but in the ascending order\n* For any kind of data normalization, executing that normalization again on normalized data should leave the result unchanged\n* If you have a serializer for your data, then for any input, `deserialize(serialize(input))` should be equivalent to `input`\n* For any random input, your program shouldn't crash\n* Your new shiny super-optimized data structure should behave the same way as the old time-proven one\n* Incrementally updating a data structure on changes in the input should be equivalent to building it anew from the input\n\nIn [IntelliJ IDEA](https://github.com/JetBrains/intellij-community) and some other [JetBrains](https://www.jetbrains.com/) IDEs, *jetCheck* is used for checking that:\n* lexer/parser never fail on any text, however broken\n* incremental lexer and parser results are consistent with full lexing/parsing \n* code completion suggests whatever you want to write, doesn't contain duplicates and doesn't fail\n* automatic code transformations don't fail, don't break compilation, don't change in presence of extra parentheses, and don't remove valuable comments\n* all internal representations (of which there are many) built for code are always synchronized\n* sorting algorithms used for completion and Project View obey transitivity contracts\n* and other things\n\n# How to use jetCheck\n\nYou can add *jetCheck* dependency to your project by using [jitpack](https://jitpack.io/#jetbrains/jetCheck). Then, in your normal test method, whatever test framework you're using, call [PropertyChecker](src/main/java/org/jetbrains/jetCheck/PropertyChecker.java). Here's a simple example of a failing property:\n\n`PropertyChecker.forAll(Generator.integers(), i -\u003e i == 42);`\n\nIf executed, it fails like this:\n\n    org.jetbrains.jetCheck.PropertyFalsified: Falsified on 0\n    Shrunk in 1 stage, by trying 1 example\n    \n    To re-run the minimal failing case, run\n      PropertyChecker.customized().rechecking(\"+/uO5x/L6LKECgEA\")\n        .forAll(...)\n    To re-run the test with all intermediate shrinking steps, use `recheckingIteration(-112063344742606325L, 1)` instead for last iteration, or `withSeed(-112063344742606325L)` for all iterations\n\nThis means that for the property `i == 42`, *jetCheck* has found and printed a counter-example: it's `0`. Of course, you'll have more complex properties working with more complex data types and generators for them. When a property-based test fails, the usual strategy is to take the printed value and create a regression unit test based on it, which you can then debug and fix.\n\nYou can also debug the property-based test itself by using `rechecking` line from the failure message. If it doesn't fail, then your test might have some unnoticed side effects, and you can debug it using more advanced `recheckingIteration` or `withSeed`, using seeds mentioned in the same message. \n\nFor writing generators and properties, see the documentation of [PropertyChecker](src/main/java/org/jetbrains/jetCheck/PropertyChecker.java) and [Generator](src/main/java/org/jetbrains/jetCheck/Generator.java) methods. For stateful system testing, see [ImperativeCommand](src/main/java/org/jetbrains/jetCheck/ImperativeCommand.java).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJetBrains%2FjetCheck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJetBrains%2FjetCheck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJetBrains%2FjetCheck/lists"}