Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what should I test for 1

Status
Not open for further replies.

dinger2121

Programmer
Sep 11, 2007
439
US
Hello,
I am building a small application that is going to be used to move a file from one folder to another in a filesystem. I know that I can accomplish by using something similar to the following -
Code:
class Test 
{
    public static void Main() 
    {
        string path = @"c:\temp\MyTest.txt";
        string path2 = path + "temp";

        try 
        {
            // Create the file and clean up handles.
            using (FileStream fs = File.Create(path)) {}

            // Ensure that the target does not exist.
            File.Delete(path2);

            // Copy the file.
            File.Copy(path, path2);
            Console.WriteLine("{0} copied to {1}", path, path2);

            // Try to copy the same file again, which should succeed.
            File.Copy(path, path2, true);
            Console.WriteLine("The second Copy operation succeeded, which was expected.");
        } 

        catch 
        {
            Console.WriteLine("Double copy is not allowed, which was not expected.");
        }
    }
}

However, I have been really trying to move more toward tdd. With that being said, what should I be testing in a simple app like this.
Here are my testing thoughts -
1. that the file to copy exists
2. that the location to copy to exists
3. that the file copied successfully

I'm not sure if there is anything else (I'm sure there is).

Does anyone have any thoughts about what else I should be testing. Also, how many classes would you think would come out of this app.

I may be overthinking some of this, so any thoughts would be great.
Thanks

carl
MCSD, MCTS:MOSS
 
this isn't really TDD. TDD is powerful for driving out the design of the work flow. this is a simple copy/paste applet. you can definitely provide some simple tests to make sure it works.
the test would be considered "integration" tests since they will operate directly against the file system. that's not a problem though since this is a very low level operation.
the only "gotcha" to watch out for is making sure you setup and tear down the testing environment correctly.

I would design the system to take the source and destination file names from an external source. this will make it much easier to test and maintain.

either hard code the values in the app.config appsettings or take the arguments as input parameters.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
So it is not necessarily beneficial to test a simple app like this?

That's what I was thinking from the beginning - that it might be overkill to try to test such a simple - but I didn't know how to justify it.


carl
MCSD, MCTS:MOSS
 
looking over the code a second time, there isn't a need to test this code. your are testing the BCL objects, and it's safe to assume they work correctly :)

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top