jsonSchema 单测重构 JUnit Jupiter

这篇具有很好参考价值的文章主要介绍了jsonSchema 单测重构 JUnit Jupiter。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

Refactor test resources to separate JSON Schema Test Suite files from project specific files · Issue #692 · networknt/json-schema-validator · GitHub

fixed by https://github.com/networknt/json-schema-validator/pull/697

i propose moving the specification files from JSON Schema Test Suite to . This would provide the following benefits:src/test/suite

  • Makes merging updates from that project into this one easier as it reduces the chance of removing or overwriting this project's files
  • Makes it easier to see exactly what changed in the specification thus making it easier to see what functional changes are required to conform (e.g., moved from to and was removed)content.jsondraft2019-09/optionaldraft2019-09draft2019-09/optional/zeroTerminatedFloats.json
  • Enables the opportunity to populate by linking to that project thus eliminating the need to manually merge its changes into this project (it is also possible for Maven to download and unpack a specific version of the source code)src/test/suite
  • Enables more complicated processing of specification files. JSON Schema Test Suite has informed validators to expect specification files to appear at the root of the folder. The validators are now expected to extract from the specification file rather than using the folder name (e.g., tests$schematests/draft2019-09)

This change depends on #690 being accepted.

Refactor unit-tests from JSON Schema Test Suite · Issue #690 · networknt/json-schema-validator · GitHub

fixed by Uses JUnit dynamic tests to generate tests from specification files by fdutton · Pull Request #691 · networknt/json-schema-validator · GitHub

JSON Schema Test Suite has several tests for each test-case and there is one or more test-cases in each specification file. Currently, this project treats each specification file as a single unit-test. As a result, a single test failure causes the unit-test to fail and no subsequent tests are performed. If the first test in a specification file fails, for example, no other tests are executed.

Several specification files are currently disabled simply because a single test fails. For example, content.json has four test-cases with a total of 18 tests. The unit-test is disabled so none of the tests are executed.

I propose refactoring the unit-tests to use JUnit Jupiter's dynamic test facility to create a separate unit-test for each test in a test-case (and each test-case in a specification file). This would provided several benefits:

  • Better test coverage since more tests are actually executed
  • Better reporting since each test is a single line-item in the report
  • Better reporting of the issue found (e.g., each test can report more detailed information than "expected true but was false")
  • Easier to investigate the cause of some obscure bugs such as JSON Schema Syntax Validator #285, V2019-09 not validating field type under properties #313 and V2020-12 not validating items: { "type" } correctly #587
  • More fine-grained control over which tests are excluded (i.e., instead of excluding a whole specification file, support excluding a specific test-case or individual test)

The specification files also need refreshing but that is best left to a separate ticket.

This is an example of how this would appear when executed from the command line.

<span style="color:#1f2328"><span style="background-color:#ffffff"><span style="color:var(--fgColor-default, var(--color-fg-default))"><span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><code>[INFO] +--JSON Schema Test Suite - 1.063s
[INFO] |  +-- [OK] validation of duration strings (src/test/resources/draft2019-09/optional/format/duration.json) Draft 2019-09 no elements present - 0.001s
[INFO] |  +-- [XX] validation of duration strings (src/test/resources/draft2019-09/optional/format/duration.json) Draft 2019-09 no time elements present - 0s
[INFO] |  +-- [OK] validation of duration strings (src/test/resources/draft2019-09/optional/format/duration.json) Draft 2019-09 no date or time elements present - 0s
</code></span></span></span></span>

This is how it appears in Eclipse (IntelliJ has similar views).
 

jsonSchema 单测重构 JUnit Jupiter,json,github

jsonSchema 单测重构 JUnit Jupiter,json,github文章来源地址https://www.toymoban.com/news/detail-603515.html

到了这里,关于jsonSchema 单测重构 JUnit Jupiter的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包赞助服务器费用

相关文章

  • 报错:TestEngine with ID ‘junit-jupiter‘ failed to discover tests

    报错:TestEngine with ID ‘junit-jupiter‘ failed to discover tests

    把包 import org.junit.jupiter.api.Test; 改成 import org.junit.Test; 然后就好了!!!

    2024年02月11日
    浏览(11)
  • TestEngine with ID ‘junit-jupiter‘ failed to discover tests异常问题处理

        今天在接手的项目中本想在测试类中跑一遍持久层的逻辑,但是测试类型项目启动就报错,报错信息如下:     仔细检查之后发现pom.xml中不仅添加了 spring-boot-starter-test 依赖,还添加了 spring-test 依赖,将 spring-test 注释掉之后项目启动成功,猜测原因可能是项目启动先执行的是

    2024年02月15日
    浏览(12)
  • 【御控工业物联网】JAVA JSON结构转换、JSON结构重构、JSON结构互换(5):对象To对象——转换映射方式

    【御控工业物联网】JAVA JSON结构转换、JSON结构重构、JSON结构互换(5):对象To对象——转换映射方式

    JSON结构转换指的是将一个JSON对象或JSON数组按照一定规则进行重组、筛选、映射或转换,生成新的JSON对象或数组的过程。这种转换可以包括改变JSON数据的结构、提取特定字段、合并多个JSON数据,或者对数据进行计算和处理等操作。 在JSON结构转换中,常见的操作包括: 提取

    2024年04月27日
    浏览(7)
  • jsonschema,一个超强的 Python 库!

    jsonschema,一个超强的 Python 库!

    📚 个人网站:ipengtao.com 大家好,今天为大家分享一个超强的 Python 库 - jsonschema。 Github地址:https://github.com/python-jsonschema/jsonschema JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,广泛用于数据传输和配置文件。为了确保JSON数据的有效性和一致性,需要使用JSON Sc

    2024年01月16日
    浏览(8)
  • spring boot 单元测试JUnit5使用MockMvc调用get请求,post请求,设置head请求头,解析返回值json和字符串

    spring boot 单元测试JUnit5使用MockMvc调用get/post接口 源码地址:https://gitcode.net/qq_39339588/springboot.git 1. 先准备一份controller,一会儿供测试调用 2. MockMvc测试调用get请求接口 两个注解说明 @SpringBootTest // 加测试类上,标明是测试的类 @AutoConfigureMockMvc // 支持对MockMvc对象的注入和配置,

    2024年02月14日
    浏览(12)
  • github前端开源json2html

    github前端开源json2html

    前端低代码工具包,通过 JSON 配置就能生成各种页面。 json解析 超大数据动态渲染,渲染速度、性能解决问题 vue3 (cdn模式开发) element plus node http-server axios 1.环境准备下载node:https://nodejs.org/en/download 2.cmd窗口输入:npm install http-server -g 3.将需要转换的JSON文件放入项目工程的

    2024年02月15日
    浏览(8)
  • 【HDFS单测】与单测编写相关的一些工具类及方法(大纲篇)持续更新

    MiniDFSCluster 可以用这个类创建一个单进程的DFS集群用来进行单元测试。 一般是采用MiniDFSCluster$Builder去建造出一个MiniDFSCluster对象。builder可以指定很多参数 获取cluster里的某个DataNode对象 【HDFS】单测中MiniDFSCluster获取某个DataNode对象 MiniRouterDFSCluster 用来模拟一个有多台Router的

    2024年02月16日
    浏览(9)
  • github.com/json-iterator/go 详细教程

    最近接触到了 github.com/json-iterator/go , 是由滴滴开源的第三方json编码库,它同时提供Go和Java两个版本。 文中大量内容来自 github 上的 wiki 文档,有兴趣的朋友可以直接点击 Home 跳转到官方文档查阅。 本文加了些自己的思考以及相关的详细学习例子,废话不多说了,冲!!!

    2024年02月11日
    浏览(10)
  • 单测的思路

    单测的思路

    单元测试(Unit Testing)是一种软件开发中的测试方法,它的主要目的是确保软件中的最小可测试单元(通常是函数、方法或类)在被单独测试和验证时能够按照预期工作。尽管单元测试有很多优点,如提高代码质量、减少Bug、简化调试过程等,但它也存在一些缺点: 增加开发

    2024年02月19日
    浏览(13)
  • 如何写好单测

    如何写好单测

    单测即单元测试(Unit Test),是对软件的基本组成单元进行的测试,比如函数、过程或者类的方法。其意义是: 功能自测,发现功能缺陷 自我Code Review 测试驱动开发 促进代码重构并提升代码质量 单测质量最直接表现的指标就是代码覆盖率,分为语句覆盖(Statement coverage)、

    2024年02月06日
    浏览(9)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包