当在浏览器中运行时,是否有方法获得JUnit代码覆盖率?



我们目前正在为我们的一个JS库获得更好的代码覆盖率。我已经启动并运行了the Intern,并且可以在浏览器中运行测试。然而,我们的库在某些函数中创建了DOM元素,这使得我们无法从终端运行JUnit,因为Node.js不允许在测试中构建DOM。当我们在浏览器中运行the Intern时,是否有一种方法可以让我们在html和控制台输出上获得JUnit代码覆盖率?

我找到了答案。从这个链接:https://theintern.github.io/intern/#local-selenium

Using ChromeDriver (Chrome-only)
If you’re just looking to have a local environment for developing functional tests, a stand-alone ChromeDriver installation works great.
1. Download the latest version of ChromeDriver
2. Set tunnel to 'NullTunnel'
3. Run chromedriver --port=4444 --url-base=wd/hub
4. Set your environments capabilities to [ { browserName: 'chrome' } ]
5. Run the test runner

设置好并运行后,可以运行

node_modules/intern/bin/intern-runner.js  config=tests/intern reporters=JUnit filename=junit.xml

这将允许测试在chrome实例中运行,然后将结果输出到可以上传到某处的报告中。

最新更新