问题标签 [spock-reports]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
4062 浏览

testing - 非程序员是否可以使用 Spock 阅读文档?

FitNesse 具有 wiki 风格的文档功能。它为这些规范测试提供了代码和文档。

Spock 中是否有办法(使用插件?/开箱即用?)生成任何类型的类似文档以向项目经理/利益相关者炫耀,他们不能期望阅读 Spock 的(Groovy)源代码规格。

0 投票
1 回答
294 浏览

grails-2.0 - 为什么 Spock Speck 测试如此冗长?

来自 JUnit 背景,我并不真正理解 spockD 测试中所有文本的意义,因为它们没有显示在测试的输出中。

因此,例如,如果我对具有约束 foo max:5, nullable:false 的字段 Double foo 有约束

我写这样的测试:

该测试在其源代码中有详细记录,但如果验证失败,则错误输出不会利用我为使测试清晰而所做的所有这些额外输入。

我得到的只是

但是我无法从这个报告中看出它是否未能通过空约束或最大约束验证,然后我需要检查测试源中失败的行号。

至少使用 JUnit 我可以做到

然后我会从失败报告中得到有用的信息。这似乎更简洁,并提供了更丰富的测试失败报告。

是否有某种方法可以从 Spec 中获得更强大的错误报告,利用所有这些类型的 when 和 then 子句,以便它们显示在失败报告中,以便您知道实际失败的原因?这些“when”和“then”文本描述符是仅用作内部源文档还是在某处使用?

0 投票
1 回答
1206 浏览

testing - Spock & Spock Reports:如何“捕捉”并自定义 AssertionError 的错误消息?

我正在与:

  • 斯波克核心
  • 斯波克报告
  • 斯波克弹簧
  • Spring MVC 测试

我有以下代码:

此处代码失败(预期如何),因为正在测试的方法确实返回 (MediaType.APPLICATION_JSON)而不是(MediaType.APPLICATION_XML).

所以说的原因@FailsWith(java.lang.AssertionError.class)

即使我使用@FailsWith(value=java.lang.AssertionError.class, reason="JSON returned ...")我也无法reason通过Spock Reports看到

问题一:我怎样才能看到reasonSpock Reports?。

我知道 Spock 提供了throw()方法,因此我能够做到:

遗憾地抛出不适用于 AssertionError。

如果我使用thrown(AssertionError)的测试方法不通过,唯一的方法是通过,@FailsWith但我无法从 AssertionError获取错误消息

问题二如何从 AssertionError中获取错误消息?

我知道我能够做类似的事情

但只是好奇是否可以解决问题二..

0 投票
1 回答
1937 浏览

testing - Spock & Spock 报告:如何在标签/块中打印有价值的变量

我正在与:

  • 斯波克核心
  • 斯波克报告
  • 斯波克弹簧
  • Spring MVC 测试

我有以下代码:

两个观察:

:观察given: "The URL being used is: /personas/xml/personas"手动添加 URL/URI 值的位置。

url变量怎么定义实例变量,因为它在很多测试方法中很常见。所以def String url

我的问题是:

如何在Spock标签/块url中显示变量?如何(给定,然后……)?它通过Spock Reports打印并改进我的测试文档

我已阅读以下内容: Spocklight:展开描述的额外数据变量

它在@Unroll周围工作。但我确实意识到围绕where标签/块的所有工作。

我已经尝试过类似的东西:

并且不工作

我想使用类似于以下的语法来解决:

那么什么是正确的配置呢?

假设我PersonaUrlHelper.FINDALL在一些 Spring@RequestMapping和这个测试方法中使用了重构。我不想手动更新given标签/块中的文本

那么正确的语法是什么?

0 投票
0 回答
303 浏览

spock - Spock & Spock 报告如何检索 where 块的 MockHttpServletResponse(来自 Spring MVC 测试)?

我正在与

  • 摇篮
  • Spring MVC 测试
  • 斯波克核心
  • 斯波克弹簧
  • 斯波克报告

在某些规范中,我有以下内容:

我能够做到以下几点:

到这里为止,我可以安心MockHttpServletResponse上课并打印一些数据。因此MockHttpServletResponse 不是 null

但后来:

我明白了

即使我将变量声明为静态或使用@Shared

我明白了

美妙的 NullPointerException。

需要什么配置设置呢?

Α

0 投票
2 回答
915 浏览

java - Spock Framework: How to create a customized Data Provider

I am working with:

  • Spring MVC
  • Spring MVC Test
  • Spock Framework

About Spock working with @Unroll I have the following situation about the where block

I can have the following:

Here the part where that is annoying in some way is that the data must be similar about the amount of items or structure, in this case by 2.

I mean, the following fails:

How you can see now methodNameReport has one item.

Spock throws an exception.

Since I can test many URLs, it makes verbose be repeating the ControllerSupportTest.METHODNAME_FINDONE_BYID term many times as many times I use ControllerSupportTest.createUrl#() where # would be 5 for example

In some way I can handle in the following way:

Note: It is a Java class

Until here I have two kinds of problems

  1. I must control always the counter
  2. If I add a new variable for the where block, such as mediaType, then I must create a new method such as methodNames()
  3. Always I must repeat the same data for each item in the array such as ControllerSupportTest.METHODNAME_FINDONE_BYID

For the two previous points, it is reflected as below:

For example:

I need something more practical

I've read the following post from SO too

But for my situation I don't want use CSV yet.

Other approach is through SQL such as:

But again, for my situation I don't want use SQL yet.

For me is more interesting this approach:

In that post he has:

See the MultilineProvider code from the post.

therefore I want do the following:

Requirement:

I want return through the MyDataSetUtil.theMethod()(see the line shown above) a collection where each item represent the same than

To let me easily add a new variable in the where block and update the Java class quickly and avoid repeat the same data many times.

What could be the best approach? Remember the code should be based in Java.

I did a research on Google without a solution.

If you have a better suggestion, it is welcome

0 投票
1 回答
2601 浏览

groovy - Groovy 不满足条件

这里有问题,我真的厌倦了试图找到解决方案......

每次我使用这个:

我收到这样的错误消息:

我真的被困在了这一点上。有人可以帮我找出解决方案吗?

0 投票
1 回答
940 浏览

gradle - 应用程序日志中的 Spock 测试输出

除了整合的 HTML 或 XML 报告,我如何才能获得 Spock 测试执行控制台输出或类似于我的应用程序日志?

使用由 log4j 支持的 Gradle 2.11 和 Slf4j。

0 投票
1 回答
647 浏览

geb - 如何将图像添加到报告中

我是 spock-reports 的新手,我想知道如何将图像添加到报告中?目前我正在使用 Geb,我想在 spock-report 中添加 Geb 生成的屏幕截图

0 投票
1 回答
552 浏览

automation - 将 serenity/thucidydes 与 spock 相结合

我正在使用 selenium webdriver 和 spock 框架进行自动化测试。我想知道如何将 serenity 与 spock 测试结合起来?我的项目是用 gradle 构建的,而 groovy 是用于编写测试的语言。任何示例类文件或链接将不胜感激。

谢谢,房车