How do you check to see if an object works in vs2005 standard?

  • Thread starter Thread starter Andy B
  • Start date Start date
A

Andy B

I have an object i want to test before putting into real code. How do i do
that in vs 2005 standard?
 
Andy B said:
I have an object i want to test before putting into real code. How do i do
that in vs 2005 standard?

Um, what kind of code is it in now?
 
Andy,

You should probably look into a unit testing package like NUnit, as I
don't think the Standard edition has the testing tools available to it.
NUnit should integrate with VS.NET 2005. There are other unit testing
packages out there as well you could look into. Just google for them.
 
what do you mean by what code is it in? the object is c# and it is supposed
to be used anywhere its needed like a website or c# program
 
Andy B said:
what do you mean by what code is it in? the object is c# and it is supposed
to be used anywhere its needed like a website or c# program

What I meant was, you said you had an object working. What I take it now to
mean is you had a csharp class (code) working. So you actually have some
test code already. I guess I was confused by this versus real code. Now it
sounds like you want a test between your development project and some
production code. Nicholas has pointed you to some options on that.

Sorry for my confusion, but I didn't want to guess at what your original
post meant.
 
I need to make sure that the code works right. For example, I need to take
data types, objects and classes/collections and "test" them seperately as
well as together. What I mean by testing, is to be able to take an object
inside a dll, create instances of it without any other code running and then
inspect how the code actually runs before putting it in the project. Its
like looking at a class that is running in memory all by itself so you can
see if things are going right. I have heard of something in vs2005 standard
called object test bench. Any idea what that is and how to use it?
 
Andy B said:
I need to make sure that the code works right. For example, I need to take
data types, objects and classes/collections and "test" them seperately as
well as together. What I mean by testing, is to be able to take an object
inside a dll, create instances of it without any other code running and then
inspect how the code actually runs before putting it in the project. Its
like looking at a class that is running in memory all by itself so you can
see if things are going right. I have heard of something in vs2005 standard
called object test bench. Any idea what that is and how to use it?

I've never used object test bench, but I *seem* to remember that it's
an ad-hoc interactive approach. Personally I far prefer the
repeatability of unit tests.

Write a test for the correct behaviour, preferably before implementing
that behaviour, and keep the test after it works. That way you'll know
if you break anything when you need to change the class for some other
reason.
 
How do you write a test? and where do you put it? The dll is going to be in
a website project (it is already in the solution for the website)...
 
Andy B said:
How do you write a test? and where do you put it? The dll is going to be in
a website project (it is already in the solution for the website)...

I personally create a separate project in the same solution, and create
tests using NUnit. Read examples etc on the nunit.org website for more
information.
 
How do you write a test? and where do you put it? The dll is going to
be in a website project (it is already in the solution for the
website)...


Jon Skeet said:
I've never used object test bench, but I *seem* to remember that it's
an ad-hoc interactive approach. Personally I far prefer the
repeatability of unit tests.

Write a test for the correct behaviour, preferably before
implementing that behaviour, and keep the test after it works. That
way you'll know if you break anything when you need to change the
class for some other reason.


Using either NUnit or VS Team System, a typical test would look
something like this.... (The only difference between the two are the
attributes - i'm using NUnit Attributes - but the principal is exactly
the same.)

I suggest visiting www.NUnit.org


[TestFixture]
public class MyObjectTestFixture
{
MyObject _testObj;

[SetUp]
public void Setup()
{
_testObj = new MyObject();
}

[Test]
public void
{
_testObj.Name = "foo";

string expected = "foo";
string actual = _testObj.Name;

Assert.AreEqual(expected, actual);
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top