编写用于mongodb连接的单元测试-Java中的MongoClient

时间:2019-03-19 09:49:53

标签: java unit-testing junit mockito junit4

我有以下方法尝试连接到我的mongodb服务器

public MongoClient connectToDatabase(String env){
    if(env.equals("PROD")){
        mongoClient = new MongoClient(new MongoClientURI(prop.getProperty(Constants.PrimaryPROD)));
        logger.info("Prod Connection established");
    }
    else{
        mongoClient = new MongoClient(new MongoClientURI(prop.getProperty(Constants.PrimaryUAT)));
        logger.info("UAT Connection established");
    }

return mongoClient;
}

现在我想在Java中对此方法执行单元测试。怎么做?

0 个答案:

没有答案