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?
that in vs 2005 standard?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
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?
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
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?
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)...
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);
}
}
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.