验证 class 生成测试任何协议 (TAP)
Verify class producing Test Anything Protocol (TAP)
我想为 class 编写单元测试,生成 Test Anything Protocol (TAP) via tap4j. How could I verify the result which is internally retrieved from TapProducer#dump(TestSet)
?
除了一堆预定义的字符串外,我还考虑了 InstantTAP 之类的东西来根据规范进行测试,但在本地进行。对我可以使用的库有什么建议吗?
我通过使用 tap4j Parser
解决了这个问题,如果给定的字符串违反规范,它会抛出 ParserException
:
Parser parser = new Tap13Parser( "UTF-8", true, true );
parser.parseTapStream( tapStream );
三个参数defined如下:
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
查看 this 问题以了解如何检索编码常量。
我想为 class 编写单元测试,生成 Test Anything Protocol (TAP) via tap4j. How could I verify the result which is internally retrieved from TapProducer#dump(TestSet)
?
除了一堆预定义的字符串外,我还考虑了 InstantTAP 之类的东西来根据规范进行测试,但在本地进行。对我可以使用的库有什么建议吗?
我通过使用 tap4j Parser
解决了这个问题,如果给定的字符串违反规范,它会抛出 ParserException
:
Parser parser = new Tap13Parser( "UTF-8", true, true );
parser.parseTapStream( tapStream );
三个参数defined如下:
encoding
- Encoding. This will not matter when parsing sources that are already decoded (e.g.String
orReadable
), but it will be used in theparseFile(java.io.File)
method (whether or not it is the right encoding for theFile
being parsed).
enableSubtests
- Whether subtests are enabled or not
planRequired
- flag that defines whether a plan is required or not
查看 this 问题以了解如何检索编码常量。