Code Monkey home page Code Monkey logo

Comments (2)

jkronegg avatar jkronegg commented on July 22, 2024

I agree that "Then" step definitions should have at least one assert. But asserts should be optional for "Given" and "When" step definitions:

  • "Given" step definitions defines the testing context : you could use assert to ensure your testing context is coherent (e.g. no negative number of cukes)
  • "Then" step definitions define some action to do on the testing context : you could use assert to ensure your testing context is coherent (e.g. number of cukes has been defined)

So the @given "I have {int} cukes in my belly" example should be replaced with a @then step definition to make the issue more coherent.

By the way, it is true that this @given example is not very good as it creates a Belly but this object instance is automatically deleted by the JVM when the method ends, so it cannot be used in another step definition (the line 8 Belly belly = new Belly(); should be defined as a field to do so).

from cucumber-java-skeleton.

mpkorstanje avatar mpkorstanje commented on July 22, 2024

You are looking at an intentionally incomplete project. The When and Then steps are present in the scenario:

Feature: Belly
Scenario: a few cukes
Given I have 42 cukes in my belly
When I wait 1 hour
Then my belly should growl

And this example project was written using a test driven approach. So just enough code has been written to get the tests running and failing. When run Cucumber will complain about two missing step definitions. You can add those and then incrementally implement the scenario.

This is great for people who are learning TDD, but probably less useful as a minimal working example. Please do feel free to workshop a better but still minimal example.

from cucumber-java-skeleton.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.