473,394 Members | 1,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

mocking a resource like a directory in unit testing

34
I need to mock a resource like a directory in one of my unit tests.
The method is checking if the directory exists and i don't want to create a directory just for testing purposes so is there anyway to mock the resource without actually creating it or is it a good idea to create the directory when setting up the fixture?
May 25 '08 #1
3 1822
RedSon
5,000 Expert 4TB
I need to mock a resource like a directory in one of my unit tests.
The method is checking if the directory exists and i don't want to create a directory just for testing purposes so is there anyway to mock the resource without actually creating it or is it a good idea to create the directory when setting up the fixture?
In your test fixture create the directory then run the test then delete the directory. You should be able to use known good directory creation APIs to make the file then use those same APIs to delete the file after you are done with it.
May 29 '08 #2
andho
34
thanks that works fine.

But would that create any adverse effect if im testing it in a checked out repository (from SVN, CVS or sort) and then commiting the changes later?

Well anyway i just wanted to know if it was a good idea so thanks :)
May 30 '08 #3
RedSon
5,000 Expert 4TB
thanks that works fine.

But would that create any adverse effect if im testing it in a checked out repository (from SVN, CVS or sort) and then commiting the changes later?

Well anyway i just wanted to know if it was a good idea so thanks :)
No SVN/CVS has no knowledge of directories in your working repository unless you add it.
May 30 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: | last post by:
Hi! I'm looking for unit-testing tools for .NET. Somthing like Java has --> http://www.junit.org regards, gicio
4
by: Peter Rilling | last post by:
Does VS.NET 2005 Professional support integrated unit testing, or is that only with the team system?
2
by: jd1978 | last post by:
I don't have Team System, but I'd like to be able to unit test the code in my app_code directory using nunit, or something else. Is there any way to do this? I can't add a reference from another...
72
by: Jacob | last post by:
I have compiled a set og unit testing recommendations based on my own experience on the concept. Feedback and suggestions for improvements are appreciated: ...
10
by: gamename | last post by:
Hi, Currently, I'm using CUnit as a unit test tool. But there is one thing it really lacks: function mocking. In other words, changing what really gets called in subordinate routines so that a...
6
by: Silfheed | last post by:
Heyas So we have the following situation: we have a testee.py that we want to automatically test out and verifiy that it is worthy of being deployed. We want our tester.py to test the code for...
0
by: Olorin | last post by:
Hi all. In one of our classes I defined a .Files property that exposes an instance of the HttpFileCollection class. At runtime this instance will be retrieved from...
0
by: mo.sparrow | last post by:
The advantages of unit testing are well known, giving development teams a safety net to facilitate change, ease integration and supply live documentation.Unit testing of small logical code is quite...
0
by: mo.sparrow | last post by:
The advantages of unit testing are well known, giving development teams a safety net to facilitate change, ease integration and supply live documentation.Unit testing of small logical code is quite...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.