Solved

How should I organize my VB.net project (classes, modules, etc.?)

Posted on 2009-04-09
3
701 Views
Last Modified: 2012-05-06
I'm trying to use convert some test automation code (currently Bash shell scripting) to VB.net, but I'm having some trouble figuring out how to organize it.  Shell scripting is very loose by nature, but I want to stay as close to possible to true VB.net OO principles, so I'm not sure where my code should be placed.

The system I'm testing has multiple components in it (a data extractor, a data mapper, etc).  And for each of these components, there are various test scenarios that need to be run.  

Currently I have all of my common test functions (logging results, checking files, defining system parameters, etc .)in classes and modules, but I'm not sure what type of file I should put the actual test scripts in?
0
Comment
Question by:jrram
  • 2
3 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24114387
That is a great question, but I don't have a specific answer, because like shell scripting, this is kind of a "loose question" without a lot of detail.  I would love to help you, so could you give me a little more detail so that I might give you suggestions?
0
 
LVL 13

Author Comment

by:jrram
ID: 24120801
Ok, hopefully this helps.  Let's take the data extractor that I need to test.  Some of the test scenarios I have are:

Test Case #1) Test to make sure the extractor can can connect to a database.
Test Case #2) Test to make sure the appropriate errors are thrown when all needed input isn't provided
Test Case #3) Test to make sure data is pulled from source system correctly.

Each of these test cases use common functionality like connecting to a database or unzipping the software before the test begins.  I have put this common functionality in "modules".

When my program starts a form is displayed which asks the user which test cases they want to run.  After this is done, i want to launch each test case.

My question is should I put the code that performs each test case in a class file, a module file, or something else?:

====================================

Public Class Extractor_TestCase_1

 'Insert Code

End Class

and call it like:

Dim myTest as New Extractor_TestCase_1
MyTest.SomeSubOrFunction

or

Module Extractor_TestCase_1

  'Insert Code

End Module

and call it like:

Extractor_TestCase_1.SomeSubOrFunction


====================================

I guess I'm just confused on when I should put code in a module vs. class vs. something else.  I've heard that common functionality should be placed in a module, but since all of my test cases are unique, I'm not sure if this is the proper place.  When I think about putting it in a class, it doesn't seem right to place it here either.

How would you approach this?


0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 300 total points
ID: 24127460
If you are looking to test your code, and you have classes that you can test, then it might be possible to automate the test with Visual Studio.NET Team Suite (with unit testing), or NUnit.

I don't use modules with VB.NET, since they are just compiled as classes with shared (static) members by the CLR anyways, so why not just cut out the middle-person.  It is a great choice to have common functionality in classes, so that you can create instance of those classes from the testing side, and exercises the methods that do the "heavy lifting" in your application.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help with concatenating data from one data element to another using VB.NET 3 39
Vb.net dynamic formulas in runtime 11 75
.NET 2008 VB and C# 6 28
VB.net and sql server 4 36
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question