简体   繁体   English

java.lang.assertionError:预期为“已更新”,但为“值”

[英]java.lang.assertionError: expected “updated” but was “value”

i am having three methods in my test case. 我在测试用例中有三种方法。 1.add 2.update 1.添加2.更新

while i am updating i am using the following code in my test case 当我更新时,我在测试用例中使用以下代码

@Test
    @Rollback(true)
    public void testUpdateCoupon() {
        CouponDO couponDO = getCoupon();
        try {
            couponDAOImpl.addCoupon(couponDO);
            couponDO.setType(2);
            couponDAOImpl.addCoupon(couponDO);
            couponDAOImpl.getCoupon(couponDO.getDiscountId());
            couponDAOImpl.updateCoupon(couponDO);
            Assert.assertEquals("Coupon updated", couponDO.getType());
        } catch (CrafartDataException cdExp) {
            cdExp.printStackTrace();
            Assert.fail();
        }
    }

but it shows an error java.lang.assertionError: expected but was<2>( 但它显示错误java.lang.assertionError:预期但为<2>(

从代码看来,您似乎正在检查Coupon updated2相等性,根据代码将type设置为2。如果您使用的是enum则可以将enum String值用于2,否则您将需要使用2而不是Coupon updated

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.AssertionError:JSON 路径中没有值 - java.lang.AssertionError: No value at JSON path java.lang.AssertionError:java.lang.AssertionError:期望的:lastName是必需的实际的:loginName是必需的 - java.lang.AssertionError: java.lang.AssertionError: Expected :lastName is required Actual :loginName is required java.lang.AssertionError:预期结果不正确[1019.1690418083019],但发现[755.0] - java.lang.AssertionError: Incorrect result expected [1019.1690418083019] but found [755.0] java.lang.AssertionError:预期状态:&lt;200&gt;但原为:&lt;201&gt; - java.lang.AssertionError: Status expected:<200> but was:<201> java.lang.AssertionError:预期状态:&lt;200&gt;但原为:&lt;404&gt; - java.lang.AssertionError: Status expected:<200> but was:<404> java.lang.AssertionError:预期状态:&lt;200&gt;,但在静态服务中为:&lt;404&gt; - java.lang.AssertionError: Status expected:<200> but was:<404> in restful services java.lang.AssertionError:预期:-1.0 实际:&lt;12.0&gt; - java.lang.AssertionError: Expected :-1.0 Actual :<12.0> java.lang.AssertionError:预期状态:&lt;201&gt;,但之前是:&lt;400&gt; - java.lang.AssertionError: Status expected:<201> but was:<400> java.lang.AssertionError:预期状态:&lt;200&gt;但原为:&lt;405&gt; - java.lang.AssertionError: Status expected:<200> but was:<405> java.lang.AssertionError:预期状态:&lt;200&gt;但原为:&lt;302&gt; itShouldAllowAccessToSecuredPageForPermittedUser - java.lang.AssertionError: Status expected:<200> but was:<302> itShouldAllowAccessToSecuredPageForPermittedUser
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM