Giter Club home page Giter Club logo

jgiven's People

Contributors

aaschmid avatar achimh3011 avatar actions-user avatar ahus1 avatar airblader avatar albertofaci avatar andru47 avatar catchin avatar cirquit avatar codecholeric avatar cptblackadder avatar dependabot[bot] avatar fudler avatar hankem avatar jangalinski avatar janschaefer avatar johthor avatar jsalinaspolo avatar l-1squared avatar laurinvesely avatar leimer avatar nikowitt avatar originx avatar renovate-bot avatar renovate[bot] avatar rubbiroid avatar sheamunion avatar triplenail avatar wolfs avatar wuan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jgiven's Issues

Nested Steps

The idea of steps is the following. Often you want to hide certain details of a step, because they are not directly important for a certain scenario. For example:

when().I_fill_out_the_registration_form_with_valid_values();

will fill out the registration form with valid values, but the concrete values are not shown. If a developer is interested in the concrete values she can look into the implementation of the step. However, in the report these details are completely gone. Thus, if someone reads the report and he wants to know the values, he has to ask a developer.

Nested Steps

Nested steps are steps that happen within another step. For example, the above step could be defined as follows:

public SELF I_fill_out_the_registration_form_with_valid_values() {
    return I_enter_as_name("Franky")
        .and().I_enter_as_email_address("[email protected]")
        .and().I_enter_as_password("password1234")
        .and().I_enter_as_repeated_password("password1234");
}

The idea is now that in the generated report these sub-steps can be made visible somehow. For example by expanding the parent step. That way, the original scenario stays small, but the details can still be looked up.

Annotation

Nested steps should get an additional annotation @NestedSteps to indicate that the step contains sub-steps.

NotImplementedYet: negate result instead of ignoring test

Consider the following scenarios:

Given a failing test for an unimplemented feature
and the test has a @NotYetImplemented annotation
When JGiven is run
Then the test is executed
and the test passes
and the output makes it clear that this test passes because it actually fails, but has the annotation

Given a passing test for an implemented feature
and the test has a @NotYetImplemented annotation
When JGiven is run
Then the test is executed
and the test fails
and the output makes it clear that this test fails because it claims not to be implemented yet

Would this maybe be a good idea? Currently, annotating tests with @notimplementedyet is a bit of an annoyance because a developer needs to remove the annotation to run the test and see if it passes.
The new behavior would also enforce the TDD idea, that the test must fail before the implementation is done (as a "passing" test with annotation would actually fail).

Structure Tags and Classes in HTML reports

Currently test classes and tags in the navigation bar at the left are not further structured. When the number of classes and tags get large, there is no overview anymore.
Test-Classes could be structured by their package name, this could even be hierarchical. Tags should at least be structured by their type.

Allow for commenting of steps

It is already possible to provide an extended description to steps by using the @ExtendedDescription annotation. However, sometimes you want to comment a certain step-invocation and not all invocations of that step. This comment should also appear in the report.

Example:

given().something();
when().some_step()
  .and().some_surprising_step()
   .comment("a comment is especially important here because the step surprises the reader")
  then().something();

Remove log4j usage

In com.tngtech.jgiven.impl.util.ReflectionUtil there is a reference to log4j. This seems to be inconsistent with the usage of slf4j in the rest of the project. This means I can't use JGiven in a project that uses a different slf4j back-end.

Switching to the slf4j Logger seems to be trivial.

HTML-Escape parameters in HTML report

Given a Scenario with HTML tags in step or method parameters
when the HTML report is generated
then the parameters are escaped in the resulting report

@Description does not work on test names

The following code does not work as expected as the @Description annotation is ignored:

@Test
@Description("My 'special' description")
public void my_special_description() {
   ...
}

Support more than strings as argument types in the JSON model

Currently the JSON report model of JGiven only supports strings as arguments of step methods. However, it might be useful to think about additional data types. One example would be to support lists or tables. Depending on the report generator, e.g. text or html, different representations could be chosen.

A table data type would enable to write something like this:

given().the_following_users_are_logged_in( new Object[][] { 
 { "First Name", "Last Name", "Email" },
 { "Joe", "Doe", "[email protected]" },
 { "Lisa", "May", "[email protected]"}});

The corresponding step method would define the argument as a table:

public SELF the_following_users_are_logged_in( @Table Object[][] data ) {
...
}

In the JSON model this data must be stored in a special way, so that the report generators can present the content accordingly.

Tag URL is not correctly encoded

Given a scenario
and the scenario has a tag with value #42
and the HTML5 report has been generated
when trying to click on the corresponding tag
then the tag page is not opened

Singleton Stages

It would sometimes be useful to have stages that live longer than a single scenario. For example, to do expensive setups that can be reused between tests. In JUnit this is typically done by using @BeforeClass annotations. However, that requires to have static fields which has several drawbacks.

Idea: Introduce a new kind of stage, namely singleton stages. Singleton stages can live longer than a single scenario and are reused between scenarios. In contrast to normal stages, a singleton stage can only be injected, it cannot be a real scenario stage.

  • Singleton stages can provide values to other stages, but no values are injected back into a singleton stage
  • Singleton stages only support @BeforeStage, @AfterStage, and @ScenarioRule life-cycle anotations.

Example:

public class MySingletonStage {
    @ProvidedScenarioState
    protected ExpensiveRessource expensiveRessource;

    @BeforeStage
    protected void setupExpensiveRessource() {
         expensiveRessource = ... // create ressource
    }

    @AfterStage
    protected void shutdownExpensiveRessource() {
         expensiveRessource.shutdown();
    }
}

Usage in other stage:

public class MyNormalStage {
    @SingletonStage
    protected MySingletonStage mySingletonStage;

    @ExpecedScenarioState
    protected ExpensiveRessource expensiveRessource;


}

Indicate number of cases in the scenario headline

As scenarios are now initially collapsed it is difficult to see whether a scenario consists of multiple cases or not. To solve this one could indicate the number of cases in the headline of the scenario.

Empty argument strings are not visible in the HTML report

Current Behavior

Given a scenario
  and the scenario has one step with an empty string as argument
when creating the HTML report
  then the empty string is not visible in the report

Expected Behavior

Given a scenario
  and the scenario has one step with an empty string as argument
when creating the HTML report
  then the empty string is displayed as '<empty>' in a gray color

Highlight differences in cases that cannot be shown as data tables

When two scenario cases have a structural difference, so that a data table cannot be created, highlight the difference so that the reader can faster grasp the difference.

Example:

Case 1:
Given something
When foo
Then bar

Case 2:
Given something
When foo
   and buzz  <-- highlight this line
Then bar

Name of stage is discarded when first stage method is hidden

Given a WhenExecuteApplication stage with a hidden method

@Hidden
public WhenExecuteApplication an_error_is_expected() {
    return this;
}

and a test with the first call to the When stage being the hidden method

@Test
public void test() {
    given().nothing();

    when().an_error_is_expected()
        .and().something_happens();

    then().nothing();
}

when the test is executed

then the output discards the "when" in the output

Given nothing
And something happens
Then nothing


The correct output instead should be

Given nothing
When something happens
Then nothing

Refactor: Introduce @Title tag, deprecate @Description tag

The @Description tag on test methods and step methods is somehow misnamed. In fact it is not a description but the title. So instead a @Title annotation should be introduced and the @Description tag should be deprecated. In a next step the @Description annotation should get the meaning of the @ExtendedDescription annotation.

Tests failed on 653d231 using locale ```de_DE.UTF-8```

Excerpt from jgiven-core/target/surefire-reports/TEST-com.tngtech.jgiven.report.model.ReportModelBuilderTest.xml

  <testcase name="printf_annotation_uses_the_PrintfFormatter" classname="com.tngtech.jgiven.report.model.ReportModelBuilderTest" time="0.04">
    <failure message="expected:&lt;&apos;5[.]20&apos;&gt; but was:&lt;&apos;5[,]20&apos;&gt;" type="org.junit.ComparisonFailure"><![CDATA[org.junit.ComparisonFailure: expected:<'5[.]20'> but was:<'5[,]20'>
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at com.tngtech.jgiven.report.model.ReportModelBuilderTest.printf_annotation_uses_the_PrintfFormatter(ReportModelBuilderTest.java:191)
]]></failure>
  </testcase>

Meta Tags

As a developer,
I want to be able to organize my tags hierarchically,
so that I get a better overview over my tags.

Idea:
Allow tags to be tagged by meta-tags. These meta-tags should also appear in the report and should allow for a hierarchical structuring of the tags in the report.

Example:
In order to hierarchically structure features under the meta-tag @Feature. We define an annotation @Feature:

@IsTag
@Retention( RetentionPolicy.RUNTIME )
public @interface Feature { }

Then we annotated feature tags with that tag:

@Feature 
@IsTag( type = "Feature", value = "Data Tables",
    description = "In order to get a better overview over the different cases of a scenario<br>"
            + "As a human,</br>"
            + "I want to have different cases represented as a data table" )
@Retention( RetentionPolicy.RUNTIME )
public @interface FeatureDataTables { }

The resulting report should then show something like this:

Feature
 - Data Tables
 - ...

It should also be collapsible

Support extended Descriptions

It would be nice if one could add an extended description to a step method. This could be shown in the report as a tooltip, for example. The extended description could provide more detailed information about a step.

Example:

class GivenCustomer {

   @ExtendedDescription("Sets up a default customer in the database."
      + "<br>The customer has name 'John' and lastname 'Doe' " 
      + "as well as email address '[email protected]'");
   public void a_customer() {
       ...
   }
}

For sure it would be nice if instead the JavaDoc of the method could be used, but that would require a separate parsing of the Java source, so this would be rather difficult to achieve without major effort.

Simplify static html report

Now that the new HTML5 Report exists, it is not necessary anymore to have a sophisticated static html report. Instead the static html report should be very basic again. This means:

  • Remove search functionality
  • Remove collapsing of scenarios
  • Remove dependency to font awesome
  • Remove the navigation panel on the left, instead just provide a breadcrumbs line

JGiven is not working with JUnit DataProvider v1.9.0

When trying to use JGiven together with version 1.9.0 of the JUnit DataProvider, the following exception is thrown:

java.util.EmptyStackException
    at java.util.Stack.peek(Stack.java:85)
    at com.tngtech.jgiven.junit.ScenarioReportRule.getTestCaseModel(ScenarioReportRule.java:25)
    at com.tngtech.jgiven.junit.ScenarioTest.<init>(ScenarioTest.java:13)
    at com.tngtech.jgiven.junit.DataProviderTest.<init>(DataProviderTest.java:22)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:195)
    at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:244)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:241)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at com.tngtech.java.junit.dataprovider.DataProviderRunner$2.evaluate(DataProviderRunner.java:162)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Typo in readme

The command to run the HTML generator in the readme is:

java com.tngtech.jgiven.report.html.HtmlReportGenerator [--dir=<jsonreports>] [--toDir=<targetDir>]

But should be (todir instead of toDir)

java com.tngtech.jgiven.report.html.HtmlReportGenerator [--dir=<jsonreports>] [--todir=<targetDir>]

HTML Report: Failed page does not contain scenarios that have some successful cases

Given the following scenario:

@Test
public void some_scenario() {
   given().something();

   assertThat(true).isFalse();
}

In practice a scenario could fail for other reasons, for example JUnit rules.

In the HTML report the scenario is marked as success, but still a failure message is shown. Expected behavior: the overall scenario is marked as failed.

The scenario also does not appear in the 'failed.html' page

Create data tables for arbitrary arguments

Currently JGiven creates data tables if parameters of cases are different. However, if arguments differ that are no parameters, data tables are not generated.
Example:

Case 1: a = 5
Given some 5
When foo 6
Then bar

Case 2: a = 7
Given some 7
When foo 8
Then bar

As the argument of foo is not a parameter, no data table is generated.

Desired output:

Given some <a>
When foo <b>
Then bar

|  a  |  b  |
|  5  |  6  |
|  7  |  8  |

The name of the variable should be derived from the variable name of the called method

Arguments in Plain Text Reports are replaced by parameter placeholders

Given a scenario with parameters 'param1'
and the scenario has 2 cases
and case 1 has argument 'baz1'
and case 2 has argument 'baz2'
and all cases have a step 'foo' with argument 'bar'
when creating the text report
then the report contains 'foo '
but it should contain 'foo 'bar''

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.