2

I'd like to write a unit test for a class that produces a Test Anything Protocol (TAP) via tap4j. How could I verify the result which is internally retrieved from TapProducer#dump(TestSet)?

In addition to a bunch of predefined strings, I thought about something like InstantTAP to test against the specification, but locally. Any suggestions on libraries I could use?

beatngu13
  • 7,201
  • 6
  • 37
  • 66

1 Answers1

0

I sort of solved this by using a tap4j Parser which would throw a ParserException if the given string violates the specification:

Parser parser = new Tap13Parser( "UTF-8", true, true );
parser.parseTapStream( tapStream );

The three parameters are defined as follows:

  • encoding - Encoding. This will not matter when parsing sources that are already decoded (e.g. String or Readable), but it will be used in the parseFile(java.io.File) method (whether or not it is the right encoding for the File being parsed).

  • enableSubtests - Whether subtests are enabled or not

  • planRequired - flag that defines whether a plan is required or not

Check out this question to see how to retrieve constants for encodings.

Community
  • 1
  • 1
beatngu13
  • 7,201
  • 6
  • 37
  • 66