3

Is it possible to use JGiven (with or without Spring support) to retrieve the statements before / during execution? For example, if we had a fairly typical login acceptance test i.e.

public class LoginFeatureTest extends SpringScenarioTest<GivenIAmAtTheLoginPage, WhenILogin, ThenTheLoginActionWillBeSuccessful> {

    @Test
    public void my_login_test() {

        given().I_am_a_new_user()
         .and().I_am_at_the_login_page();

         when().I_login_with_username_$_and_password_$("dave", "dave123");

         then().the_home_page_is_visible();

    }

}

Is it possible to get something access to the following information?

My Login Test (start)
    Given I am a new user
      and I am at the login page   
     When I login with username dave and password dave123
     Then the home page is visible
My Login Test (end)

i.e. what i'm looking for is: -

  1. The name of a scenario method + all it's given, when, then and and statement calls _(formatted via JGiven formatting).
  2. When each scenario method starts at run-time.
  3. When each given, when, then and and executes at run-time.
  4. When the scenario method ends.

This will give me the ability to visually show in a UI (a) exactly what is going to execute and (2) it's current position during execution (with durations).

12:00:01.012         [ My Login Test (start) ]
12:00:02.035   23ms     Given I am a new user
12:00:02.051   16ms       and I am at the login page   
   ---->                 When I login with username dave and password dave123
                         Then the home page is visible
                     [ end ]

I'm thinking Spring AOP might come to the rescue here? Or does JGiven provide anything useful buried in it's code?

bobmarksie
  • 3,282
  • 1
  • 41
  • 54

1 Answers1

0

At the moment there is no possibility to do that. I have created an issue for that: https://github.com/TNG/JGiven/issues/328.

It should not be too difficult to implement this as there is internally already a listener concept. If you are still interested you could propose an API and integrate the mechanism in JGiven.

Jan Schaefer
  • 1,882
  • 1
  • 18
  • 23