0
votes

I am using selenium/Cucumber and junit runner class to execute my scripts. I want to use assertion in cucumber to verify my test output, can some please write me an example how to do the same in cucumber.

As I googled, I found that people use junit/TestNG assertions like below: assertTrue(selenium.isTextPresent("Name of the Customer"));

Can I use the same assertions in cucumber test and how? Thanks!!

1
Yes, you can use same - Murthi

1 Answers

2
votes

Cucumber as such does not contain any assertion framework.

An assertion is a comparison of values. If the comparison fails, an exception is thrown. This means that you can build you own comparison or use a library such as JUnit or AssertJ. The signaling is the same, an exception is thrown and the execution of a scenario is halted.

You may be interested in a detailed example on how to use this. One that I have written and presented at Java Developer Day is available on my blog.