当前位置:网站首页>Unit testing with mongodb
Unit testing with mongodb
2022-07-01 05:05:00 【Superior virtue and weak water】
problem :
My database of choice is MongoDB. The database I chose is MongoDB.I'm writing a data-layer API to abstract implementation details from client applications - that is, I'm essentially providing a single public interface (an object which acts as an IDL). I am writing a data layer API To abstract the implementation details from the client application - in other words , I actually provide a separate public interface ( One acts as IDL The object of ).
I'm testing my logic as I go in a TDD manner. I'm taking TDD To test my logic .Before each unit test, an @Before method is called to create a database singleton, after which, when the test completes, an @After method is called to drop the database. Before each unit test , call @Before Method to create a database singleton , after , When the test is complete , call @After Method to delete the database .This helps to promote independence among unit tests. This helps to improve the independence between unit tests .
Nearly all unit tests, ie performing a contextual query , require some kind of insertion logic to occur before hand. Almost all unit tests , namely Execute context query , All need some kind of insertion logic in advance .My public interface provides an insert method - yet, it seems incorrect to use this method as precursor logic to each unit test. My public interface provides an insertion method - However , It seems incorrect to use this method as the precursor logic of each unit test .
Really I need some kind of mocking mechanism, yet, I haven't had much experience with mocking frameworks, and it seems that Google returns nothing re a mocking framework one might use with MongoDB. I really need some sort of simulation mechanism , however , I don't have much experience with simulation frameworks , and Google It doesn't seem to return any possibility with MongoDB Simulation framework used together .
What do others do in these situations? What others have done in these situations ?That is, how do people unit test code that interacts with a database? in other words , How do people unit test code that interacts with databases ?
Also, my public interface connects to a database defined in a external configuration file - it seems incorrect to use this connection for my unit testing - again, a situation that would benefit from some kind of mocking? Besides , My public interface connects to the database defined in the external configuration file - It seems incorrect to use this connection for unit testing - Again , This situation will benefit from some kind of simulation ?
Solution :
Reference resources : https://stackoom.com/en/question/V6iP边栏推荐
- STM32扩展板 数码管显示
- Pico neo3 handle grabs objects
- [daily question in summer] function of rogu p3742 UMI
- [summer daily question] Luogu p5886 Hello, 2020!
- Technology sharing | broadcast function design in integrated dispatching
- LeetCode_58(最后一个单词的长度)
- Global and Chinese market for kitchen range hoods 2022-2028: Research Report on technology, participants, trends, market size and share
- 【暑期每日一题】洛谷 P1629 邮递员送信(未完待续...)
- STM32 extended key scan
- Global and Chinese market of broadband amplifiers 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
![[hard ten treasures] - 1 [basic knowledge] classification of power supply](/img/a8/f129c9d15ca6ed99db1dacfc750ead.png)
[hard ten treasures] - 1 [basic knowledge] classification of power supply

智慧运维:基于 BIM 技术的可视化管理系统

复制宝贝提示材质不能为空,如何解决?

RuntimeError: mean(): input dtype should be either floating point or complex dtypes. Got Long instead

Neural network - nonlinear activation

Leetcode316- remove duplicate letters - stack - greedy - string

分布式-总结列表

How to use common datasets in pytorch

Copier le matériel de conseils de bébé ne peut pas être vide, comment résoudre?

Use and modification of prior network model
随机推荐
[data recovery in North Asia] a data recovery case of raid crash caused by hard disk drop during data synchronization of hot spare disk of RAID5 disk array
[daily question in summer] letter delivery by p1629 postman in Luogu (to be continued...)
C read / write application configuration file app exe. Config and display it on the interface
Global and Chinese markets of superconductor 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese markets of InGaAs APD arrays 2022-2028: Research Report on technology, participants, trends, market size and share
线程安全问题
LeetCode_28(实现 strStr())
LeetCode_35(搜索插入位置)
FileInputStream
Oracle views the creation time of the tablespace in the database
Global and Chinese market of digital badge 2022-2028: Research Report on technology, participants, trends, market size and share
技术分享| 融合调度中的广播功能设计
[NLP Li Hongyi] notes
Global and Chinese market of search engine optimization (SEO) software 2022-2028: Research Report on technology, participants, trends, market size and share
STM32 expansion board digital tube display
Solve the problem that the external chain file of Qiankun sub application cannot be obtained
Global and Chinese market of metal oxide semiconductor field effect transistors 2022-2028: Research Report on technology, participants, trends, market size and share
担心侵权?必备无版权素材网站分享,不用担心视频剪辑缺素材
[daily question in summer] function of rogu p3742 UMI
JS random verification code