【问题标题】:Strange JUnit/Google Endpoint test result奇怪的 JUnit/Google Endpoint 测试结果
【发布时间】:2016-11-04 11:05:09
【问题描述】:

我有以下测试方法来测试在 Objectify 数据存储中创建合作伙伴实体。

我得到了异常的 DuplicateRecordException,但是当我尝试检索实体(该类中的任何实体)时,我得到了一个空值。知道我错过了什么吗?

注意:我启动了本地 API 资源管理器来测试 createPartner() 方法,结果很好。

@Test
public void  testCreatePartner(){
    try {
        Partner p = createPartner(instID, displayName, new Text(aboutMe));
        createPartner(instID, displayName, newText(aboutMe));

        assertNull(p);

    } catch (DuplicateRecordException | MissingIDException | FailToSaveRecordException e) {
        //e.printStackTrace();
        log.severe("======> "+e.getMessage());
        Partner q = OfyController.ofy().load().type(Partner.class).first().now();

        if (q!=null) {
            log.info("------>>" + q.getDisplayName());
        }
    }
}

【问题讨论】:

    标签: java google-app-engine android-studio junit objectify


    【解决方案1】:

    解决了!

    我也有这个:

    new LocalDatastoreServiceTestConfig().setDefaultHighRepJobPolicyUnappliedJobPercentage(100)
    

    我将 100 更改为 1,它起作用了。

    【讨论】:

    • 您可能希望在测试中使用.setApplyAllHighRepJobPolicy()
    猜你喜欢
    • 2014-04-13
    • 1970-01-01
    • 1970-01-01
    • 2012-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-04
    • 2016-03-19
    相关资源
    最近更新 更多