[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How can we use Visual Studio Testing to unit test a form

Posted on 2008-06-11
12
Medium Priority
?
247 Views
Last Modified: 2013-11-26
I'm trying to set up a unit test to simulate a user entering information onto a form created in VB.NET.  I see a load of examples for testing classes on the web, but nothing that goes through testing a form which is compromised of 95% subs - not functions.  I know I can set it up to run the Form Load events, etc - but I cannot simulate the addition of test in many of my field since we use many user controls and the actual text properties for controls within the users controls are Read Only as they should be.  

I'm basically looking for a site with information on how to test a class that inherits from Form.  I know this will be hard to actually explain in this forum, but a simple link to a good site would be great.  Thanks!
0
Comment
Question by:CyprexxDev
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
12 Comments
 
LVL 12

Expert Comment

by:renjurdevan
ID: 21766308
please go through the link below

http://www.nunit.com/index.php
0
 
LVL 1

Author Comment

by:CyprexxDev
ID: 21769916
That site has a testing add-in, but does not explain how to test a Windows Form Application.  

More specifically, the application we're developing is composed of numerous forms.  If I try to test certain routines in one form, often times there is code that will open another form based on user input.  Of course, during a test I don't want these other forms opening since it stops the test.  I'm just not sure at all that anything in the test environment was developed for forms as I see nothing indicating this online or in Microsoft's documentation.  Every example I've found is for testing functions within a  basic class.
0
 
LVL 12

Expert Comment

by:renjurdevan
ID: 21775937
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:CyprexxDev
ID: 21874896
As I said in my previous reply, this site gives examples on a Class, not a Form.  The second paragraph starts off saying:

Suppose we are writing a bank application and we have a basic domain class  Account.

I want examples on how to test a form, not a class.  A form has button click events, etc...  that these examples do not have.
0
 
LVL 24

Accepted Solution

by:
Jeff Certain earned 2000 total points
ID: 21879663
0
 
LVL 14

Expert Comment

by:jake072
ID: 21883576
Nothing will replace or can replace having a few people still down and hammer on it.

Just my opinion, but trust me, it works.  Give it to a buddy and ask him to break it.  He will.

Jake
0
 
LVL 1

Author Comment

by:CyprexxDev
ID: 21886530
I'll take a further look at that post Chaosian.  Thanks for the link - it seems to answer the question.

Jake, I agree with you completely.  We would, however, like to use the testing functionality provided by VS to at least set up a regression testing scenario that can be run after each release build.  Our application is gigantic - it would take hours to test each release without some automated script.  I'd like to at least eliminate 75% of this work.
0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 21886707
Gald to help.

Jake -- that's why I had a PM who pressed buttons at random until something broke...
0
 
LVL 14

Expert Comment

by:jake072
ID: 21887060
- I know what you guys mean.  I just don't understand (I could just be an idiot) the advantages that a scripted testing system would provide.  So you script it to do something, how do you know that it worked, or are you just looking for exceptions, rather than behavior?  For instance, you could have a method that does something in a DB.  It might not throw an exception, but it might not work properly either...

Am I missing something?  Just curious!

Jake
0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 21887212
Unit testing provides a few benefits. (And yes, database testing is a challenge).

First, it lets you know that the piece of code you're testing works properly. this is done at a fine-grained level, and allows you to test boundaries and exceptions. Any bug that is found in these functions is really two bugs -- one in the code and one in the test suite.

Second, when you're done with a piece of code, you're *done*. Move on. Check it in. It's complete, and you know you're not going to have to come back to it. The unit tests provide a regression test suite, so that you can be assured that your later code hasn't broken stuff you thought you were done with. (Or, you know it before it goes out the door).

Third, you can adopt development methodologies that test the code as it is written (TDD, BDD, etc). This gives you the ability to correct your code while the context is still fresh in your mind. You can also build your unit tests into source control and continuous integration, so you know immediately that your code base is always buildable and correct (or as correct as your test suite).
0
 
LVL 1

Author Comment

by:CyprexxDev
ID: 21887869
Exactly...  We won't use unit testing to make sure that the forms will update the database correctly from the start (though I would like to get to this point).  There are things, however, that it's very nice for.  For instance, when we make a change in the database, such as changing the name of a field, we want to make sure all Stored Procedures are updates with that new field name (which is impossible on the DB end as far as I know).  What we can do, however, is run a unit test on the application side to make sure that all previous forms that used those SPs will open properly, that all dialogues will still be displayed as intended, etc.  The moment a form opens that calls an SP where that field name was changed, there will be an exception on the applciation side.  Due to the fact that we have 100s of forms, we don't want to have someone go in and make sure they all still work after every change.

This is obviously a glaring example of how this would benefit, but there are lesser obvious circumstances.  Anyway, I've been busy all day and haven't had time to look at the link.  I'm going to assign points based on the fact that this page at least looks like what I need based on the question I asked.  If it's not, it's still the first reply that directly answers the question.  Thanks Chaosian!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

649 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