如何将数据从.properties文件动态加载到我的jBehave故事文件中?我一直在我的故事文件中使用$,如:
When the stock is traded at price : $<price>
Then the alert status should be $<status>
我正在尝试从我的src / test / resources文件夹下的属性文件中获取值,并在pom.xml中包含我的.properties文件,如
<testResource>
<directory>${basedir}/src/test/resources</directory>
<filtering>false</filtering>
<includes>
include>**/*.properties</include>
</includes>
</testResource>
但它仍然不起作用。 当我尝试运行&#34; mvn integration-test&#34;在我的cmd上。它抛出了我的异常
org.json.JSONException: A JSONObject text must begin with '{' at character 1
at org.json.JSONTokener.syntaxError(JSONTokener.java:410)
at org.json.JSONObject.<init>(JSONObject.java:179)
at org.json.JSONObject.<init>(JSONObject.java:402)....
我不知道我哪里出错了。请帮帮我。 等待回复!! -Tester
答案 0 :(得分:0)
参数由Examples语句提供。您可能对此部分很熟悉,但未将其包含在您的示例故事中:
When the stock is traded at price : <price>
Then the alert status should be <status>
Examples:
|price|status|
|10.00|low|
|20.00|medium|
|50.00|high|
我不相信使用$与&lt;&gt;组合使用已验证。 我建议使用&lt;&gt;而不是$,因为后者在JBehave尝试找到匹配步骤时可能不明确。
然而,您可能不知道的是,上面故事的最后四行(示例和三条数据行)可以保存为文本文件,然后通过文件名在故事中引用,允许要动态更改的示例表。
Examples:
TableFiles/storystats.table
也许这就是你要找的东西。