-1

I am working with java and cucumber. In my step def I found that assertion is not working. Even if I write

assert 1==2

exception is not thrown. I know that I do not provide too much info, but the problem I do not know what start to check. Any idea what it can be?

Jacob
  • 1,135
  • 5
  • 14
  • 29
  • 1
    The `assert` keyword is not related to Cucumber at all, it's just plain Java. If it's not working, it's probably because you are executing the code without enabling assertions. How are you running the code? e.g. [see this question on enabling assertions in Eclipse](https://stackoverflow.com/questions/11415160/how-to-enable-the-java-keyword-assert-in-eclipse-program-wise) – anotherdave Aug 12 '17 at 07:59
  • yep, you are right. I confused it with junit assert. I'll change it. But just for knowledge, how I enable assert in java? I run it in intellij as cucumber test. – Jacob Aug 12 '17 at 08:01
  • Did you read the question I linked to above? What didn't make sense about the answer? What else did you try that didn't work? – anotherdave Aug 12 '17 at 08:13

1 Answers1

0

Assert works in Cucumber + Java on IntelliJ. I have been using it for months.

Example: Assert.assertEquals(status, "Success");

This is because I'm using TestNG in my code.

In your class, make sure you have imported import org.testng.Assert;

For details, you can have a look at this git code: SeleniumCucumberGradle

Ashish Deshmukh
  • 448
  • 4
  • 17