Munit4 投掷"org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(



我尝试在我的单位测试中模拟一个变量;

<munit:behavior >
<set-payload value='xxxxx' doc:name="Set Payload" doc:id="597412dc-64c7-45e0-87c5-2e8ce3dd967e" mimeType="application/json"/>

<munit-tools:mock-when doc:name="Mock when" doc:id="fe3ee162-0a52-4b4d-a5bf-127b42b7f6b6" processor="set-variable">
<munit-tools:with-attributes >
<munit-tools:with-attribute whereValue="ClientId" attributeName="doc:name" />
<munit-tools:with-attribute whereValue="clientid" attributeName="variableName" />
</munit-tools:with-attributes>
<munit-tools:then-return >
<munit-tools:variables >
<munit-tools:variable key="clientid" value="ss" />
</munit-tools:variables>
</munit-tools:then-return>
</munit-tools:mock-when>
</munit:behavior>
<munit:execution >
<flow-ref doc:name="Flow-ref to post:raml-main" doc:id="de9bf3d4-cd3f-42e1-89cf-621c3852634e" name="raml-main"/>
</munit:execution>
<munit:validation >
<munit-tools:assert-that doc:name="Assert that" doc:id="292449c4-51e6-4135-afba-c56016b5ef7d" is="#[MunitTools::equalTo(200)]" expression="#[vars.httpStatus]" message="Different status code"/>
</munit:validation>

但是当我运行测试时; 我得到;

caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#1679456e': FactoryBean threw exception on object creation; nested exception is org.mule.runtime.core.api.config.ConfigurationException: Element 'ss' is not defined in the Mule Registry
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:185) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:137) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:302) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
...........
Caused by: org.mule.runtime.core.api.config.ConfigurationException: Element 'ss' is not defined in the Mule Registry

为什么?我已选择要测试的流。我的测试具有测试属性文件,该文件正在工作。 我已经定义了喜欢;

为什么我不能模拟变量?

我刚刚遇到了你的问题。 我一直在研究同样的问题。 我相信如果你使用 value="#["ss"]"它会起作用。 我试图将 200 放入一个名为 httpStatus 的变量中,这似乎对我有用。

<munit-tools:variables >
<munit-tools:variable key="httpStatus" value="#[200]" />
</munit-tools:variables>    

以下内容对我有用。我正在使用 mule 4.3 和 munit2。

<munit-tools:variables >
<munit-tools:variable key="clientid" value='#["ss"]' />
</munit-tools:variables>

相关内容

最新更新