如果不使用karate-junit5进行测试,它的目的是什么? [英] What's the purpose of karate-junit5 when you can run tests without it?

查看:28
本文介绍了如果不使用karate-junit5进行测试,它的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

空手道文档中有2个使用空手道和JUnit5进行测试的示例:

  • 但是,在我看来,一旦习惯了看空手道输出的HTML报告,就不需要JUnit集成.

    总结:JUnit支持是

    a),因为我们以Cucumber扩展名开始(甚至不建议使用 @KarateOptions 注释)

    b),因为有些人喜欢IDE集成+经验,因此一次运行一个测试"非常有用.在开发模式下

    您的评论使我更加相信,我们最终可以弃用JUnit支持.一旦您有更多机会玩这个游戏,将会很高兴获得您对此的反馈.

    The Karate docs have 2 examples of testing with Karate and JUnit5:

    I created a project using only karate-core (0.9.9-RC2) with the second example and don't need karate-junit5. What is the difference?

    I'm very impressed with what Karate is offering and I'm interested in creating a test harness that could need to pick tests out according to runtime criteria and will also need custom reporting so I'm looking at the easiest ways of hooking into the test runner. The code in karate-junit5 seems a good starting point but I just want to understand why it is not actually necessary for normally running tests.

    解决方案

    Great question and I can answer this. You are right, directly using the Runner class is sufficient, and this is the only way to run tests in parallel.

    However, if you use the JUnit runner you get the "green bar" experience you are used to as a Java developer and we make sure the IDE UI (e.g the tree-view of tests run and failures etc) is populated. In IntelliJ you even see the logs when you click on one of the "test case" nodes if I remember right.

    EDIT: note that I mean here you can see the data of each Scenario in the IDE, not the Java class of the containing JUnit test. Screenshot of IntelliJ below. So this can be convenient to quickly see what failed and the corresponding error message without having to dive into logs / HTML reports:

    But once you get used to looking at the HTML reports that Karate outputs, in my opinion - you don't need the JUnit integration.

    To summarize: the JUnit support is

    a) because we started as a Cucumber extension (there is even a @KarateOptions annotation that is being deprecated)

    b) because some folks like the IDE integration + experience and it is useful to run "one test at a time" in dev-mode

    Your comment makes me more convinced that we can eventually deprecate the JUnit support. Would be good to get your feedback on this once you have had a chance to play around more.

    这篇关于如果不使用karate-junit5进行测试,它的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆