简体   繁体   English

使用Couchbase进行单元和集成测试

[英]Unit & Integration Testing with Couchbase

I recently setup a new project that is using Spring-Data-Couchbase and I am completely stumped on how I should approach unit and integration testing here. 我最近建立了一个使用Spring-Data-Couchbase的新项目,而我对如何在此处进行单元和集成测试完全感到困惑。

Typically with JPA I can mock out my Repository somehow (assuming this is similar for couchbase with Spring) and this is okay for unit testing, but normally for JPA I wire up an in memory database and have a full integration testing suite. 通常,使用JPA,我可以以某种方式模拟我的存储库(假设对于使用Spring的长沙发来说这是相似的),并且对于单元测试来说还可以,但是通常对于JPA,我连接一个内存数据库并具有完整的集成测试套件。 Is there any way to do this with couchbase? 有什么办法可以通过沙发床做到这一点?

Also if you don't mind mentioning any tips here as this is my first major NoSQL project :) Thanks! 另外,如果您不介意在此处提及任何提示,因为这是我的第一个主要NoSQL项目:)谢谢!

Couchbase does not run in-memory unfortunately. 不幸的是,Couchbase无法在内存中运行。 For unit testing you would have to mock Couchbase's API. 对于单元测试,您必须模拟Couchbase的API。 There is a CouchbaseMock project to facilitate that: https://github.com/couchbase/CouchbaseMock 有一个CouchbaseMock项目可以简化此工作: https : //github.com/couchbase/CouchbaseMock

There is also the possibility to use a runner prior to launching your test. 也有可能在启动测试之前使用跑步机。 There is probably a maven plugin that would allow you to run Couchbase or a Couchbase Docker image. 可能有一个maven插件可以让您运行Couchbase或Couchbase Docker映像。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM