{"id":14967450,"url":"https://github.com/skinny85/specnaz","last_synced_at":"2025-10-25T19:31:02.408Z","repository":{"id":46098091,"uuid":"65942241","full_name":"skinny85/specnaz","owner":"skinny85","description":"Library for writing beautiful, RSpec/Jasmine/Mocha/Jest-style specifications in Java, Kotlin and Groovy","archived":false,"fork":false,"pushed_at":"2023-01-08T01:50:08.000Z","size":930,"stargazers_count":34,"open_issues_count":0,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-31T10:11:42.501Z","etag":null,"topics":["groovy","jasmine","java","java8","jest","junit","kotlin","mocha","mochajs","rspec","testing","tests"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skinny85.png","metadata":{"files":{"readme":"Readme.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-17T21:09:39.000Z","updated_at":"2024-08-04T05:42:50.000Z","dependencies_parsed_at":"2023-02-08T04:16:27.978Z","dependency_job_id":null,"html_url":"https://github.com/skinny85/specnaz","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skinny85%2Fspecnaz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skinny85%2Fspecnaz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skinny85%2Fspecnaz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skinny85%2Fspecnaz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skinny85","download_url":"https://codeload.github.com/skinny85/specnaz/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238201032,"owners_count":19433128,"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":["groovy","jasmine","java","java8","jest","junit","kotlin","mocha","mochajs","rspec","testing","tests"],"created_at":"2024-09-24T13:38:04.674Z","updated_at":"2025-10-25T19:31:01.650Z","avatar_url":"https://github.com/skinny85.png","language":"Java","funding_links":[],"categories":["测试","java"],"sub_categories":[],"readme":"# Specnaz\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Download](https://maven-badges.herokuapp.com/maven-central/org.specnaz/specnaz/badge.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/org.specnaz/specnaz)\n[![Build Status](https://github.com/skinny85/specnaz/actions/workflows/build.yaml/badge.svg)](https://github.com/skinny85/specnaz/actions/workflows/build.yaml)\n\n### Library for writing beautiful, [RSpec](http://rspec.info)/[Jasmine](http://jasmine.github.io)/[Mocha](https://mochajs.org)/[Jest](https://facebook.github.io/jest)-style specifications in Java, [Kotlin](https://kotlinlang.org) and [Groovy](http://www.groovy-lang.org)\n\n![Specnaz logo](docs/img/specnaz-logo.png)\n\n### First example\n\n```java\nimport org.specnaz.Specnaz;\nimport org.specnaz.junit.SpecnazJUnit;\nimport org.specnaz.junit.SpecnazJUnitRunner;\nimport org.junit.runner.RunWith;\nimport org.junit.Assert;\nimport java.util.Stack;\n\n// You can also say:\n// public class StackSpec extends SpecnazJUnit {{\n// - in that case, you can drop the @RunWith annotation\n@RunWith(SpecnazJUnitRunner.class)\npublic class StackSpec implements Specnaz {{\n    describes(\"A Stack\", it -\u003e {\n        Stack\u003cInteger\u003e stack = new Stack\u003c\u003e();\n\n        it.should(\"be empty when first created\", () -\u003e {\n            Assert.assertTrue(stack.isEmpty());\n        });\n\n        it.endsEach(() -\u003e {\n            stack.clear();\n        });\n\n        it.describes(\"with 10 and 20 pushed on it\", () -\u003e {\n            it.beginsEach(() -\u003e {\n                stack.push(10);\n                stack.push(20);\n            });\n\n            it.should(\"have size equal to 2\", () -\u003e {\n                Assert.assertEquals(2, stack.size());\n            });\n\n            it.should(\"have 20 as the top element\", () -\u003e {\n                Assert.assertEquals(20, (int)stack.peek());\n            });\n        });\n    });\n}}\n```\n\nThis is how the above test looks like when executed from an IDE:\n\n![StackSpec result](docs/img/stack-spec-result.png)\n\n### Notable features\n\n#### Compatible with existing Java testing frameworks\n\nSpecnaz integrates with every major Java testing framework:\n\n* JUnit 4, which was shown in the above example -\n  including support for the [Rules API](docs/reference-manual.md#junit-4-rules)\n* [TestNG](docs/reference-manual.md#testng)\n* [JUnit 5](docs/reference-manual.md#junit-5)\n\nThis is important for 2 reasons.\nFirst, it means Specnaz works out of the box with your existing IDEs and build tools,\nwithout requiring the installation of any additional plugins.\nAnd second, it means adopting Specnaz is not an all or nothing decision:\nyou can introduce it gradually to your test suite, on a trial basis,\nand the new Specnaz tests and any existing JUnit or TestNG tests will coexist next to each other seamlessly.\nAdopting Specnaz does not force you into any sort of migration.\n\nSee [below](#getting-specnaz) for a summary of which Specnaz library to use with each testing framework.\n\n#### Built-in parametrized test capabilities\n\nSpecnaz allows you to easily create concise and type-safe parametrized tests.\nExample:\n\n```java\nimport org.specnaz.junit.SpecnazJUnitRunner;\nimport org.specnaz.params.SpecnazParams;\nimport org.specnaz.params.junit.SpecnazParamsJUnit;\nimport org.junit.runner.RunWith;\n\nimport static org.specnaz.params.Params3.p3;\n\n// You can also say:\n// public class ParametrizedSpec extends SpecnazParamsJUnit {{\n// - in that case, you can skip the @RunWith annotation\n@RunWith(SpecnazJUnitRunner.class)\npublic class ParametrizedSpec implements SpecnazParams {{\n    describes(\"A parametrized spec\", it -\u003e {\n        it.should(\"confirm that %1 + %2 = %3\", (Integer a, Integer b, Integer c) -\u003e {\n            assertThat(a + b).isEqualTo(c);\n        }).provided(\n                p3(1, 2, 3),\n                p3(4, 4, 8),\n                p3(-3, 3, 0),\n                p3(Integer.MAX_VALUE, 1, Integer.MIN_VALUE)\n        );\n    });\n}}\n```\n\nSee [here](docs/reference-manual.md#parametrized-test-support) for more information on writing parametrized specs.\n\n#### First-class support for the Kotlin language\n\nSpecnaz supports writing specs in idiomatic Kotlin:\n\n```kotlin\nimport org.specnaz.kotlin.junit.SpecnazKotlinJUnit\nimport org.junit.Assert\nimport java.util.Stack\n\nclass StackKotlinSpec : SpecnazKotlinJUnit(\"A Stack\", {\n    var stack = Stack\u003cInt\u003e()\n\n    it.should(\"be empty when first created\") {\n        Assert.assertTrue(stack.isEmpty())\n    }\n\n    it.endsEach {\n        stack = Stack()\n    }\n\n    it.describes(\"with 10 and 20 pushed on it\") {\n        it.beginsEach {\n            stack.push(10)\n            stack.push(20)\n        }\n\n        it.should(\"have size equal to 2\") {\n            Assert.assertEquals(2, stack.size)\n        }\n\n        it.should(\"have 20 as the top element\") {\n            Assert.assertEquals(20, stack.peek())\n        }\n    }\n})\n```\n\nSee [here](docs/reference-manual.md#kotlin) for more information.\n\n### Further reading\n\nCheck out the [reference manual](docs/reference-manual.md) for more in-depth documentation.\nThere is also an [examples directory](src/examples) with code samples.\n\nI've also written [a post on my blog](http://endoflineblog.com/specnaz-my-java-testing-library)\ndemonstrating how you can structure your tests with Specnaz.\n\n### Getting Specnaz\n\nSpecnaz is available through the [Maven Central](https://search.maven.org/search?q=g:org.specnaz) repository.\n\n* Group ID: `org.specnaz`\n* Latest version: `1.5.3`\n\nThe Artifact ID depends on the language and testing framework you want to use:\n\n| Programming language | Testing framework |           Artifact ID           |\n|----------------------|-------------------|---------------------------------|\n| Java / Groovy        | JUnit 4           | `specnaz-junit`                 |\n| Kotlin               | JUnit 4           | `specnaz-kotlin-junit`          |\n| Java / Groovy        | TestNG            | `specnaz-testng`                |\n| Kotlin               | TestNG            | `specnaz-kotlin-testng`         |\n| Java / Groovy        | JUnit 5           | `specnaz-junit-platform`        |\n| Kotlin               | JUnit 5           | `specnaz-kotlin-junit-platform` |\n\n**Note**: the Specnaz libraries don't depend on their testing frameworks\n(neither JUnit, nor TestNG), and also not on the Kotlin runtime in the case of the Kotlin libraries.\nThis is in order to prevent version conflicts.\nMake sure to add the appropriate dependencies on JUnit or TestNG \n(and the Kotlin runtime if applicable)\nif your project doesn't include them already.\n\n###### Example Maven settings\n\n```xml\n\u003cdependencies\u003e\n    \u003c!-- For JUnit 4: --\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003ejunit\u003c/groupId\u003e\n        \u003cartifactId\u003ejunit\u003c/artifactId\u003e\n        \u003cversion\u003e4.12\u003c/version\u003e\n        \u003cscope\u003etest\u003c/scope\u003e\n    \u003c/dependency\u003e\n    \u003c!-- ...in Java / Groovy: --\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.specnaz\u003c/groupId\u003e\n        \u003cartifactId\u003especnaz-junit\u003c/artifactId\u003e\n        \u003cversion\u003e1.5.3\u003c/version\u003e\n        \u003cscope\u003etest\u003c/scope\u003e\n    \u003c/dependency\u003e\n    \u003c!-- ...or Kotlin: --\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.specnaz\u003c/groupId\u003e\n        \u003cartifactId\u003especnaz-kotlin-junit\u003c/artifactId\u003e\n        \u003cversion\u003e1.5.3\u003c/version\u003e\n        \u003cscope\u003etest\u003c/scope\u003e\n    \u003c/dependency\u003e\n\n    \u003c!-- For TestNG: --\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.testng\u003c/groupId\u003e\n        \u003cartifactId\u003etestng\u003c/artifactId\u003e\n        \u003cversion\u003e6.14.3\u003c/version\u003e\n        \u003cscope\u003etest\u003c/scope\u003e\n    \u003c/dependency\u003e\n    \u003c!-- ...in Java / Groovy: --\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.specnaz\u003c/groupId\u003e\n        \u003cartifactId\u003especnaz-testng\u003c/artifactId\u003e\n        \u003cversion\u003e1.5.3\u003c/version\u003e\n        \u003cscope\u003etest\u003c/scope\u003e\n    \u003c/dependency\u003e\n    \u003c!-- ...or Kotlin: --\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.specnaz\u003c/groupId\u003e\n        \u003cartifactId\u003especnaz-kotlin-testng\u003c/artifactId\u003e\n        \u003cversion\u003e1.5.3\u003c/version\u003e\n        \u003cscope\u003etest\u003c/scope\u003e\n    \u003c/dependency\u003e\n\n    \u003c!-- For JUnit 5: --\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.junit.jupiter\u003c/groupId\u003e\n        \u003cartifactId\u003ejunit-jupiter\u003c/artifactId\u003e\n        \u003cversion\u003e5.5.2\u003c/version\u003e\n        \u003cscope\u003etest\u003c/scope\u003e\n    \u003c/dependency\u003e\n    \u003c!-- ...in Java / Groovy: --\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.specnaz\u003c/groupId\u003e\n        \u003cartifactId\u003especnaz-junit-platform\u003c/artifactId\u003e\n        \u003cversion\u003e1.5.3\u003c/version\u003e\n        \u003cscope\u003etest\u003c/scope\u003e\n    \u003c/dependency\u003e\n    \u003c!-- ...or Kotlin: --\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.specnaz\u003c/groupId\u003e\n        \u003cartifactId\u003especnaz-kotlin-junit-platform\u003c/artifactId\u003e\n        \u003cversion\u003e1.5.3\u003c/version\u003e\n        \u003cscope\u003etest\u003c/scope\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n###### Example Gradle settings\n\n```groovy\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    // For JUnit 4:\n    testCompile \"junit:junit:4.12\"\n    // ...in Java / Groovy:\n    testCompile \"org.specnaz:specnaz-junit:1.5.3\"\n    // ...or Kotlin:\n    testCompile \"org.specnaz:specnaz-kotlin-junit:1.5.3\"\n\n    // For TestNG:\n    testCompile \"org.testng:testng:6.14.3\"\n    // ...in Java / Groovy:\n    testCompile \"org.specnaz:specnaz-testng:1.5.3\"\n    // ...or Kotlin:\n    testCompile \"org.specnaz:specnaz-kotlin-testng:1.5.3\"\n\n    // For JUnit 5:\n    testCompile \"org.junit.jupiter:junit-jupiter:5.5.2\"\n    // ...in Java / Groovy:\n    testCompile \"org.specnaz:specnaz-junit-platform:1.5.3\"\n    // ...or Kotlin:\n    testCompile \"org.specnaz:specnaz-kotlin-junit-platform:1.5.3\"\n}\n```\n\n### License\n\nSpecnaz is open-source software, released under the Apache v2 license.\nSee [the License file](License.txt) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskinny85%2Fspecnaz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskinny85%2Fspecnaz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskinny85%2Fspecnaz/lists"}