|
Well not surprisingly I don't agree with the replies you have so far received.
John Simmons / outlaw programmer wrote: It seems to me that it's only real purpose is to test discrete functions and classes
NUnit is for Unit testing and discrete functions, classes and modules are the primary purpose of Unit Testing. You can however expand that meaning and the use of NUnit to be pretty much whatever you want. However I don't believe that attempting to do system testing or regression testing with Unit test tools is a very productive way to do those types of testing.
John Simmons / outlaw programmer wrote: Next, I understand that TDD is supposed to promote the building of tests before doing the actual coding
Yes, um, No, well maybe. It's like with any other process, they should be tailored to your individual environment and project.
John Simmons / outlaw programmer wrote: but what about adding nUnit to existing code?
You don't "add" NUnit to your system code. If that is what you are doing you are doing it wrong.
John Simmons / outlaw programmer wrote: It seems kinda pointless unless you're doing a ground-up redesign of your code.
No you can certainly write NUnit Unit tests for existing apps without modification to the application code base.
NOTE: We tend to put all NUnit tests in a "Test" project as part of the Solution.
John Simmons / outlaw programmer wrote: I've been a programmer for almost 30 years
Oh dear, what happened to you?
John Simmons / outlaw programmer wrote: didn't really understand the reasoning behind "extreme programming", and think "agile programming" is the sure path to failure in a production product.
The rise in popularity, as with anything in our profession, causes much abuse and misuse due to assumptions that people know what it means. Mostly they don't. There was a common struggle regarding requirements. Some assumed you should have them all before starting development. We know of course know that is very very rare as requirements almost always constantly change. Agile was borne as an attempt to standardize the fact that requirements almost always change during the original development cycle of a project. There are many different prescribed agile processes and most of them share one common trait. That you tailor the process to your environment and project. Easy to type, not so easy to do.
I have been a programmer for almost 20 years now and I have always done Unit tests. Not always test drive, and certainly not with tools like NUnit that make it a real breeze to do. I still don't do test driven in a Nazi like fashion but I agree that thinking or even writing test (in some cases) can be helpful to your thought process about designing and developing your project.
One of the most productive aspects of having Unit Tests as early as possible is that when requirements do change you can update the module and run all those tests to ensure you haven't broken anything.
Well you have probably stopped reading by now so I guess that's enough.
led mike
|
|
|
|
|
nUnit can be used with existing projects. Anytime you change code writing unit tests really helps with the testing to identify errors. You will find, however, that writing good tests cases requires a lot of time. Sometimes when I have really bad code a unit test is the only real way to identify the errors.
Also, if you find yourself testing the results from a database call you are using unit testing wrong and have slipped into integration testing which is different and the two shouldn't be mixed.
I ramble a lot, unit tests do not test the application just the code. The theory is that if your code works as promised your application is more likely to work as expected. You still need traditional testing even with the best TDD.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
I just picked up a book about TFS and Agile. The author really seemed to be saying that XP was the cure to all evils and nothing else could be used to write good software, no other methods used iterative delivery, etc.. His view also was that XP was an all or nothing thing, you either implemented in all, including paired programming, or it wouldn't work. My response to this...well, not kid sister safe.
Just like any methodology, you have to adapt it to the environment.
I think one of the misconceptions with Agile is that you don't need good, or any requirements, to do work, it will all get worked out in the iterations. The last client I was at said they were using Agile, I liked to think of the methodology as more of the pasta cook method, through it against the wall until it sticks. They were so far behind schedule because the requirements kept changing, not to mention the recreate the wheel syndrome.
As for unit testing, I always create tests (with VS) for my backend code, whether the client wants it or not. I've had too many cases where testers complained because the app wouldn't work correctly and blamed my code. Running the unit tests showed them it was either bad input or data.
Maybe someone should move this thread to the Lounge
only two letters away from being an asset
|
|
|
|
|
Welll, I'm more interested in the TDD stuff - I threw in the XP and agile thing so everyone was aware of what I skipped.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Mark Nischalke wrote: The author really seemed to be saying that XP was the cure to all evils and nothing else could be used to write good software, no other methods used iterative delivery, etc.. His view also was that XP was an all or nothing thing, you either implemented in all, including paired programming, or it wouldn't work.
While he may be right or wrong, XP is not Agile. It is only one particular agile methodology.
If you really want to know what the intention of agile is you go the horses mouth.[^]
AM is an attitude, not a prescriptive process.
led mike
|
|
|
|
|
led mike wrote: AM is an attitude, not a prescriptive process.
Yeah, thats where I've seen a lot of people go wrong with many of the methodologies. It's not about checking off on a line item, behavior has to change also.
led mike wrote: the horses mouth
Why did I have thoughts of a link to a Mr. Ed site?
only two letters away from being an asset
|
|
|
|
|
John Simmons / outlaw programmer wrote: It seems to me that it's only real purpose is to test discrete functions and classes
NUnit can be used to test your whole application, but just parts of it at a time. Unit testing doesn't work for integration tests or tests where you want to see if 2 or more components work well together. Unit testing is just that: testing a unit at a time. In practical sense, this means testing a single method at time.
There are some barriers to unit testing: if you've mixed logic code in your GUI classes, unit testing them may cause your forms and controls to show up during the unit test runs, slowing things down and making testing a real pain. That's bad. Separate your logic from your GUI and you'll be good. Then you don't write unit tests for your GUI classes since there's no logic to be tested.
Another barrier to unit testing is hard-coded dependencies on the file system, the network, databases, etc. For example, if you've got a function that should open a connection to a database, and you want to test that the database is opened, you're in a predicament: your test can actually open the database, but that can slow down unit tests and it might not work if run on certain machines. Instead of opening a real database, make your code flexible enough so that there's no hard-coded dependency on your database:
void OpenTheDatabase()
{
someSqlConnection.Open();
}
void OpenTheDatabase(IDbConnection connection)
{
connection.Open();
} Here you injec a connection object, which could be a dummy object you create in your tests:
[Test]
public void OpenTheDatabaseDoesExactlyThat()
{
DummyConnection connection = new DummyConnection();
myDataLayer.OpenTheDatabase(connection);
Assert.IsTrue(connection.Opened);
}
class DummyConnection : IDbConnection
{
public bool Opened = false;
public void Open()
{
opened = true;
}
} Ah, now your test doesn't actually talk to a database during the unit tests.
It's a contrieved example, sure, but you get the idea: replace hard-coded dependencies with fake objects. For a better example, see Martin Fowler's Dependency Injection[^] article.
Now, once you've done a few unit tests like this, you begin to realize it's really a pain to have to create dummy classes like our DummyConnection every dang time you want to replace a dependency with a fake object.
Fortunately, there are some real great pieces of code out there, mocking frameworks, that take care of this for you. At my job we use a free one called RhinoMocks[^]. With it, replacing dependencies with fake objects becomes a breeze:
[Test]
public void OpenTheDatabaseDoesExactlyThat()
{
using (rhinoMocks.Record())
{
IDbConnection fakeConnection = rhinoMocks.CreateMock<IDbConnection>();
fakeConnection.Open();
}
using (rhinoMocks.Playback())
{
myDataLayer.OpenTheDatabase(connection);
}
} Notice in the above example, there is no DummyClass we had to create. Also notice we didn't have to Assert that Open() was called on the IDbConnection object -- we just told RhinoMocks we were expecting connection.Open to be called, and that was it.
John Simmons / outlaw programmer wrote: but what about adding nUnit to existing code?
You mean unit testing already-written code? Since that code's probably gonna be hard to test, it's gonna be hard to do. Skip the elementary nUnit and go for something more powerful. TypeMock[^] allows you to unit test existing codebases that weren't built with unit testing in mind. (It's so powerful, some people look down on it[^] because it allows you to write code the "old" way: hard-coded dependencies, tight coupling, etc. and still do unit tests.)
John Simmons / outlaw programmer wrote: TDD makes a lot more sense in theory because you have to have a good design up front in order to write applicable/viable tests
Precisely. It makes you essentially write blue prints for your code before actually writing the code. If you've got tests like ListensForUserModification(), SavesToDatabaseWhenClosing(), you've got a blueprint for how your code should work, and you've already put some thought into the design before actually writing code.
|
|
|
|
|
Heres one for you all.
I need to get info out of the data base by status and the current week. This is not a problem except for that the Week needs to begin on Thursday at 5:00pm and end on Thursday at 4:59pm.
I suppose my Question is how do I set this time as my week?
|
|
|
|
|
|
Hi
I need to control Visual Studio outside of the environment (create solutions, build solutions etc) from a C# application and was going to go down the route of generating the solution and project files in code and just changing the bits I need to. However I have been reading about the VS automation model which has all the functionality to do what I need.
It appears to be for extending the environment. Is there a way interacting with Visual Studio the way you would use a COM component or does the automation model offer this and I dont realise it?
Thanks
At university studying Software Engineering - if i say this line to girls i find they won't talk to me
Dan
|
|
|
|
|
Well you can certainly build solutions from external apps like nant or msbuild does.
Why do you need to create solutions from an external application?
led mike
|
|
|
|
|
I am nearing completion of a a game making tool for my final year university project.
I have the tool creating the code files but at the moment the user would have to open Visual Studio add the files to an XNA project and then build it - the idea of the tool is that no coding is needed so I would like to hide all this from the user.
Thanks for your help I will look into those.
At university studying Software Engineering - if i say this line to girls i find they won't talk to me
Dan
|
|
|
|
|
Hey
Thanks for your help - msbuild does exactly what I want!!!
At university studying Software Engineering - if i say this line to girls i find they won't talk to me
Dan
|
|
|
|
|
hi,
I want to customize combo box such that what ever user enters in to it should appear in upper case. Please let me know
Thank You
*** Why EXPERTS behave like a fool ***
|
|
|
|
|
Hi,
there is a TextChanged event; you could attach a handler that replaces the entire
text by its uppercase equivalent.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Thank u luc pattyn ....
I have not followed your idea
I have written this in the keypress event and it worked
string str = e.KeyChar.ToString().ToUpper();
char[] ch = str.ToCharArray();
e.KeyChar = ch[0];
Regards
Sidnhu Tiwari
*** Why EXPERTS behave like a fool ***
|
|
|
|
|
Hi,
yes that works for keyboard input, but not for pasted data (CTRL/V).
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Is there a way to allocate disk space before copying a file in c#?
sample code will be greate help
Thanks
|
|
|
|
|
Are you talking about ensuring there is enough space on the disk to store the file?
Obviously, if there isn't enough space, any attempt to save it will throw an exception. You would have you free up sufficient space manually.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi,
haven't done this for a long time, but I would try and create a file, write a byte,
seek to the intended file size and write another byte; then you could rewind and
write the actual data, or close and overwrite any way you choose.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
What is the exception thrown when another thread tried to access another control which its not given the right to??
Som
|
|
|
|
|
You can check all these yourself easily enough mate...
If you want to find out the exceptions a class throws then visit MSDN and look it up there, or you can simulate the exception and it will tell you the name of it when the program crashes.
Mark.
|
|
|
|
|
hi,
i want to set the column width of DataGrid, but i dunno how to do?
because i'm not using TableStyles
codes :
DataTable DT = new DataTable();
dataGrid1.DataSource = DT;
now, how can i set width of first column ???
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Get to the dataGrid1.Columns[i] or dataGrid1.Column["name"] and set its width?
|
|
|
|
|
no, its not so easy, there is no Property named Columns in DataGrid
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|