{"id":25776929,"url":"https://github.com/Decathlon/tzatziki","last_synced_at":"2025-02-27T06:07:01.856Z","repository":{"id":38198421,"uuid":"442210080","full_name":"Decathlon/tzatziki","owner":"Decathlon","description":"Decathlon library to ease and promote Test Driven Development of Java microservices!","archived":false,"fork":false,"pushed_at":"2025-02-21T09:51:42.000Z","size":816,"stargazers_count":66,"open_issues_count":36,"forks_count":33,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-02-24T08:02:42.539Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/Decathlon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-27T16:19:50.000Z","updated_at":"2025-02-06T13:07:15.000Z","dependencies_parsed_at":"2024-02-14T13:43:49.333Z","dependency_job_id":"65ce6495-3faf-4642-b3cd-87a12f125bcb","html_url":"https://github.com/Decathlon/tzatziki","commit_stats":null,"previous_names":[],"tags_count":109,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Decathlon%2Ftzatziki","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Decathlon%2Ftzatziki/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Decathlon%2Ftzatziki/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Decathlon%2Ftzatziki/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Decathlon","download_url":"https://codeload.github.com/Decathlon/tzatziki/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240987435,"owners_count":19889335,"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:33.160Z","updated_at":"2025-02-27T06:07:01.849Z","avatar_url":"https://github.com/Decathlon.png","language":"Java","funding_links":[],"categories":["测试"],"sub_categories":[],"readme":"Tzatziki Steps Library\n======\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.decathlon.tzatziki/tzatziki-parent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.decathlon.tzatziki/tzatziki-parent)\n![Build](https://github.com/Decathlon/tzatziki/workflows/Build/badge.svg)\n[![codecov](https://codecov.io/gh/Decathlon/tzatziki/branch/main/graph/badge.svg)](https://codecov.io/gh/Decathlon/tzatziki)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n![lifecycle: beta](https://img.shields.io/badge/lifecycle-beta-509bf5.svg)\n\nThis project is a collection of ready-to-use Cucumber steps making it easy to TDD Java microservices by focusing on an\noutside-in testing strategy.\n\n## Wait, Cucumber?\n\n*You are a Cucumber veteran? ... jump directly to [Content of this project](#content-of-this-project)*\n\nOtherwise, here is what [wikipedia](https://en.wikipedia.org/wiki/Cucumber_(software)) says:\n\n\u003e Cucumber is a software tool used by computer programmers for testing other software.\n\u003e It runs automated acceptance tests written in a behavior-driven development (BDD) style.\n\u003e Central to the Cucumber BDD approach is its plain language parser called Gherkin.\n\u003e It allows expected software behaviors to be specified in a logical language that customers can understand.\n\u003e As such, Cucumber allows the execution of feature documentation written in business-facing text.\n\n*What does it mean to us developers?*\n\nCucumber provides a mapping between humanly readable test files written in a language called Gherkin and their JUnit\nimplementations. You can think about it as a partition that will execute pieces of JUnit code.\n\n*Why using Cucumber?*\n\nBy creating a separation between a test expression and its implementation, the resulting Cucumber test tends to be a bit\nmore readable than its JUnit counterpart. Additionaly, the reusability of each JUnit implementation is really high, and\nover time only the Gherkin needs to be added to test a new feature.\n\n*Okay ... so how does it work?*\n\n### Getting started with Cucumber in 5 mins\n\nThe Cucumber tests are written in `.feature` files. Most of the IDEs have support for writting, running and debugging\ncucumber tests. Since deep down they are just JUnit tests, once they are running everything should be the same: code\ncoverage, reporting etc.\n\nThe structure of a `.feature` file is the following:\n\n```gherkin\nFeature: the name of your feature\n  Here you can put some comments describing your feature\n\n  Background: some stuff that needs to be done for every scenario\n    * a system is running\n\n  @this-is-a-tag\n  Scenario: Change a state in the system\n  As a User I expect to go from A to C if B happens\n\n    Given a state A\n    When B happens\n    # we can also put comments if things need a bit of explanation\n    Then C is the new state of the system\n\n  Scenario: some other scenario\n  ...\n```\n\nThe lines starting with `Given, When, Then` are called Steps. Additional Steps keywords are `And` and `But` (`*` is also\naccepted). Those keywords don't really have a functional meaning, they are just there for us to write nice tests. We\ncould start every step with `*` and the output of the test would be exactly the same. However, you should choose the one\nfitting the most the intent of the step you are writing. A big part of the idea behind using Gherkin, is that the tests\nare the specifications of the code, so it should be enough to read them to understand the product they test.\n\nAn optional `Background` section can be added at the beginning. The steps in it will be repeated before any scenario in\nthe file, like a method annotated with `@org.junit.Before`.\n\nEach Step has an implementation in plain Java that is annotated with a regular expression matching the step.\n\nSo for example:\n\n```gherkin\nGiven that we do something\n```\n\nwill have the following implementation:\n\n```java\n@Given(\"that we do something\")\npublic void do_something(){\n  // do something here\n}\n```\n\nCucumber can extract parameters directly from a step so that:\n\n```gherkin\nGiven a user named \"bob\"\n```\n\ncan be implemented as:\n\n```java\n@Given(\"a user named \\\"(.*)\\\"\")\npublic void a_user_named(String name){\n  // create a user with that name\n}\n```\n\nBut it also supports multiline arguments:\n\n```gherkin\nGiven the following configuration file:\n  \"\"\"\n  property: value\n  \"\"\"\n```\n\n```java\n@Given(\"the following configuration file:\")\npublic void the_following_configuration_file(String content){\n  // do something with the file content\n}\n```\n\nas well as tables:\n\n```gherkin\nGiven the following users:\n  | id  | name    |\n  | 1   | bob     |\n  | 2   | alice   |\n```\n\n```java\n@Given(\"the following users\")\npublic void the_following_users(List\u003cMap\u003cString, String\u003e\u003e users){\n  // do something with those users\n}\n```\n\nThose Java methods need to be added to a Steps class, typically something like `LocalSteps`. Keep in mind that for\ntechnical reasons Cucumber will not allow you to extend those steps. Instead, the framework will enforce composition,\nand if any class extending a Steps class is detected, an exception will be thrown.\n\nCucumber also comes with support for injection frameworks, so all your dependencies will be properly instantiated and\ninjected at runtime, per scenario.\n\nNote that your `@org.junit.Before` and `@org.junit.After` annotations won't work in your steps. You need to use the\nCucumber equivalent: `@cucumber.api.java.Before` and `@cucumber.api.java.After`\n\nExample:\n\n```java\npublic class BaseSteps {\n\n    @Before\n    public void before() {\n        // something to run before each scenario\n    }\n\n    @Given(\"that we do something\")\n    public void do_something() {\n        // do something here\n    }\n}\n\npublic class LocalSteps {\n\n    private final BaseSteps baseSteps;\n\n    public LocalSteps(BaseSteps baseSteps) {\n        this.baseSteps = baseSteps;\n    }\n\n    @Given(\"a user named \\\"(.*)\\\"\")\n    public void a_user_named(String name) {\n        baseSteps.do_something();\n        // create a user with that name\n    }\n\n    @Given(\"the following users\")\n    public void the_following_users(List\u003cMap\u003cString, String\u003e\u003e users) {\n        // do something with those users\n    }\n\n    @After\n    public void after() {\n        // something to run after each scenario\n    }\n}\n```\n\nFinally, in order to have JUnit execute our Cucumber tests we need a runner:\n\n```java\npackage com.yourcompany.yourproject;\n\nimport io.cucumber.junit.Cucumber;\nimport io.cucumber.junit.CucumberOptions;\nimport org.junit.runner.RunWith;\n\n@RunWith(Cucumber.class)\n@CucumberOptions(plugin = \"pretty\")\npublic class CucumberTest {\n}\n```\n\nBy default, cucumber will look for `.feature` files in the same directory structure than the java runner. However, this\ncan be configured using the `features` property on the `@io.cucumber.junit.CucumberOptions` annotation. In addition, it\nwill also look for Java classes containing steps next to the runner and this can also be configured by using the `glues`\nproperty on the same annotation.\n\n\u003e Tip:\n\u003e Sometimes it can be hard to come up with the implementation steps...\n\u003e but if you start by typing your new step in your feature file and then execute the scenario, Cucumber will output an implementation for you:\n\n```\n  Undefined step: Given something else that is not yet implemented\n\n  Skipped step\n\n  Skipped step\n\n  Skipped step\n\n  1 Scenarios (1 undefined)\n  5 Steps (3 skipped, 1 undefined, 1 passed)\n  0m0.250s\n\n\n  You can implement missing steps with the snippets below:\n\n  @Given(\"^something else that is not yet implemented\")\n  public void something_else_that_is_not_yet_implemented() throws Throwable {\n      // Write code here that turns the phrase above into concrete actions\n      throw new PendingException();\n  }\n```\n\n## Content of this project\n\nThis repository contains several libraries, each one having its own tutorial and documentation when applicable:\n\n- [tzatziki-mapper](https://github.com/Decathlon/tzatziki/tree/main/tzatziki-mapper) : module containing only the Mapper\n  interface.\n- [tzatziki-jackson](https://github.com/Decathlon/tzatziki/tree/main/tzatziki-jackson) : Jackson implementation of the\n  Mapper.\n- [tzatziki-common](https://github.com/Decathlon/tzatziki/tree/main/tzatziki-common) : dependency module containing the\n  base classes for the core library, but without cucumber.\n- [tzatziki-core](https://github.com/Decathlon/tzatziki/tree/main/tzatziki-core) : the core library, provides support of\n  our test instances as well as input/output and time management.\n- [tzatziki-logback](https://github.com/Decathlon/tzatziki/tree/main/tzatziki-logback) : the logging library, provides\n  support for dynamically configuring the log levels in your tests.\n- [mockfaster](https://github.com/Decathlon/tzatziki/tree/main/mockfaster) : static wrapper around mockserver to reduce\n  the time taken by redefining mocks.\n- [tzatziki-http](https://github.com/Decathlon/tzatziki/tree/main/tzatziki-http) : http library encapsulating both\n  rest-assured and mockserver.\n- [tzatziki-spring](https://github.com/Decathlon/tzatziki/tree/main/tzatziki-spring) : base library to start a spring\n  service\n- [tzatziki-spring-jpa](https://github.com/Decathlon/tzatziki/tree/main/tzatziki-spring-jpa) : support for spring jpa to\n  insert and assert data in the database.\n- [tzatziki-spring-kafka](https://github.com/Decathlon/tzatziki/tree/main/tzatziki-spring-kafka) : support for spring\n  kafka listener and consumers.\n\n## Support\n\nWe welcome [contributions](https://github.com/Decathlon/tzatziki/tree/main/CONTRIBUTING.md), opinions, bug reports and\nfeature requests!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDecathlon%2Ftzatziki","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDecathlon%2Ftzatziki","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDecathlon%2Ftzatziki/lists"}