Linked Questions

205 votes
17 answers
86k views

There's a discussion going on over at comp.lang.c++.moderated about whether or not assertions, which in C++ only exist in debug builds by default, should be kept in production code or not. Obviously, ...
199 votes
9 answers
237k views

I am debugging with breakpoints and I realize the assert call? I thought it was only for unit tests. What does it do more than breakpoint? Since I can breakpoint, why should I use Assert?
Pokus's user avatar
  • 11.9k
111 votes
8 answers
24k views

I've read plenty of articles (and a couple of other similar questions that were posted on StackOverflow) about how and when to use assertions, and I understood them well. But still, I don't understand ...
user avatar
45 votes
2 answers
12k views

When should I debug.assert over code contracts or vice versa? I want to check precondition for a method and I am confused to choose one over the other. I have unit tests where I want to test failure ...
Carbine's user avatar
  • 7,913
22 votes
5 answers
4k views

I find myself writing some methods where there is a code path that should never happen. Here is a simplified example: double Foo(double x) { int maxInput = 100000; double castMaxInput = (...
William Jockusch's user avatar
10 votes
5 answers
2k views

Its been a while I have ready Mcconnell's "Code Complete". Now I read it again in Hunt & Thomas' "The Pragmatic Programmer": Use assertions! Note: Not Unit Testing assertions, I mean Debug.Assert()...
Theo Lenndorff's user avatar
15 votes
2 answers
4k views

It seems like a fairly large hassle to set up a proper debug environment in ASP.NET and I'm just wondering if using Asserts are the way to go or not. I've read a bit and saw that you need to modify ...
Joe Phillips's user avatar
  • 51.5k
2 votes
2 answers
849 views

I have seen couple of posts regarding usage of Debug.Assert in C#. But I still have one doubt, may be its repeated, but I need to ask. Is there a strict rule that Debug.Assert should be used only for ...
Sandepku's user avatar
  • 871
1 vote
2 answers
7k views

We're in a process of writing Test framework (for Integration Testings) and I have a question regarding asserts. The test code looks like that: public class MyTestClass { [Fact] public void ...
Okiba's user avatar
  • 239
1 vote
3 answers
175 views

I have a static class ArgumentHelper which can check for example: ArgumentHelper.NotNull(instance, "instance"). But it works for some standard built-in .net framework classes, if I implement my own ...
apocalypse's user avatar
  • 5,914