3

I've looked in the documentation and sample C# project: http://getgauge.io/documentation/user/current/

However, I'm not sure how to validate the response from a "Step". Maybe Gauge isn't the right tool for this but I'm trying to validate the format of a JSON response for instance.

On their standard "StepImplementation" class, I can see the following method. I added 'return "blah";' to the end:

[Step("Say <what> to <who>")]
public string SaySomething(string what, string who)
{
    Console.WriteLine("{0}, {1}!", what, who);
    return "blah";
}

And of course in the spec file:

First scenario
--------------

tags: hello world, first test

* Say "hello" to "gauge"

* Check if "blah" is returned from SaySomething

It fails on that last line because the Step isn't defined (duh). But, what I really want is something like - Say "hello" to "gauge" and expect "blah".

Srikanth Venugopalan
  • 9,011
  • 3
  • 36
  • 76

1 Answers1

4

Yeah... Apparently I wasn't fully understanding the power of Gauge and what it is designed to do. The answer to my silly question is:

Use your favorite testing framework and use Asserts. Those Assert failures will show up on the Gauge reports (even though those Asserts aren't actually coming FROM Gauge - errors will fail the Scenario/Step too). Whether you are using C# or Java, just assume that Gauge is your test runner I guess, and you can do whatever you want for validation.

  • Glad you figured this out, you can also check out a [more realistic example](https://github.com/getgauge/gauge-examples/tree/master/gauge-example-csharp) of using Gauge with C#. – Srikanth Venugopalan Dec 14 '15 at 04:52