tagged [assert]
Best practice for using assert?
Best practice for using assert? 1. Is there a performance or code maintenance issue with using assert as part of the standard code instead of using it just for debugging purposes? Is assert x >= 0, 'x...
Ignoring Exceptions in xUnit.net
Ignoring Exceptions in xUnit.net I have some cases where I don't care what exception is thrown (as long as some exception is thrown). Unfortunately, doesn't pass unless exactly an instance of `Excepti...
How can I display more info in an error message when using NUnit Assert in a loop?
How can I display more info in an error message when using NUnit Assert in a loop? Consider the following code: If one of the asserts fails, I will get a very unhelpful error message like the one belo...
- Modified
- 14 Jun at 16:2
How to combine defensive programming techniques together?
How to combine defensive programming techniques together? The question I want to ask you is quite wide but in the same time it's very concrete. First, I have to say, that I mostly interested in answer...
- Modified
- 24 Oct at 04:32
How to do a JUnit assert on a message in a logger
How to do a JUnit assert on a message in a logger I have some code-under-test that calls on a Java logger to report its status. In the JUnit test code, I would like to verify that the correct log entr...
Rhino Mocks AAA Quick Start?
Rhino Mocks AAA Quick Start? I've been looking around for some decent information on using Rhino Mocks 3.5+ with the AAA syntax. I find a lot of blogs that have a mix of things from the old and new wh...
- Modified
- 9 Sep at 10:0
Proper way to assert type of variable in Python
Proper way to assert type of variable in Python In using a function, I wish to ensure that the type of the variables are as expected. How to do it right? Here is an example fake function trying to do ...
Fluent assertions: Assert one OR another value
Fluent assertions: Assert one OR another value Using fluent assertions, I would like to assert that a given string contains either one of two strings: . This does NOT work
- Modified
- 6 Oct at 06:10
Issues in Xunit.Assert.Collection - C#
Issues in Xunit.Assert.Collection - C# I have a Class Library, it contains the following Model and Method Model: Method: ``` public class EmployeeService { public List GetEmployee() { return new...
- Modified
- 1 Apr at 16:47
Best practices for multiple asserts on same result in C#
Best practices for multiple asserts on same result in C# What do you think is cleanest way of doing multiple asserts on a result? In the past I've put them all the same test but this is starting to fe...
- Modified
- 14 Jan at 09:40
Verifying ArgumentException and its message in Nunit , C#
Verifying ArgumentException and its message in Nunit , C# In my test program in Nunit, I want to verify that it's getting the write Argument Exception by verifying the message. ``` [Test] public voi...
How does C# compiler remove Debug.Assert's in release builds?
How does C# compiler remove Debug.Assert's in release builds? I was recently going through some code and considering whether I need to be careful with the expressions placed inside `Debug.Assert` stat...
Assert.AreEqual fails while it shouldn't
Assert.AreEqual fails while it shouldn't I have a really weird behavior which I cannot explain. I have the following class: And a method which returns a `Project` object: ``` public Project GetByName(...
- Modified
- 17 Mar at 16:23
Why does Assert.AreEqual() cast to object before comparing?
Why does Assert.AreEqual() cast to object before comparing? I'm writing some unit tests and the following assertion fails: If I call this instead, it succeeds: I had assumed that `Assert.AreEqual()` u...
- Modified
- 14 Nov at 14:35
How does Assert.AreEqual determine equality between two generic IEnumerables?
How does Assert.AreEqual determine equality between two generic IEnumerables? I have a unit test to check whether a method returns the correct `IEnumerable`. The method builds the enumerable using `yi...
- Modified
- 6 Nov at 18:59
Debug.Assert vs. Specific Thrown Exceptions
Debug.Assert vs. Specific Thrown Exceptions I've just started skimming 'Debugging MS .Net 2.0 Applications' by John Robbins, and have become confused by his evangelism for Debug.Assert(...). He points...
How can I avoid multiple asserts in this unit test?
How can I avoid multiple asserts in this unit test? This is my first attempt to do unit tests, so please be patient with me. [I'm still trying to unit test a library that converts lists of POCOs to AD...
- Modified
- 23 May at 10:34