Top "Assert" questions

An assertion is a statement, which aborts a program when it evaluates to false.

How to assertThat something is null with Hamcrest?

How would I assertThat something is null? for example assertThat(attr.getValue(), is("")); But I get an error saying that …

java assert hamcrest
Static assert in C

What's the best way to achieve compile time static asserts in C (not C++), with particular emphasis on GCC?

c gcc assert compile-time static-assert
Python/Django: how to assert that unit test result contains a certain string?

In a python unit test (actually Django), what is the correct assert statement that will tell me if my test …

python json django unit-testing assert
Add custom messages in assert?

Is there a way to add or edit the message thrown by assert? I'd like to use something like assert(…

c++ assert
How to use assert in android?

I want to use assert obj != null : "object cannot be null" on Android device. The assert doesn't seem to work, …

java android assert
Use NUnit Assert.Throws method or ExpectedException attribute?

I have discovered that these seem to be the two main ways of testing for exceptions: Assert.Throws<Exception&…

c# unit-testing exception nunit assert
What does static_assert do, and what would you use it for?

Could you give an example where static_assert(...) ('C++11') would solve the problem in hand elegantly? I am familiar …

c++ debugging c++11 assert static-assert
PHPUnit: assertInstanceOf() not working

I need to check if a variable is an object of the User type. User is my class $user my …

php phpunit assert assertions
How can I completely disable calls to assert()?

My code is full of calls to assert(condition). In the debug version I use g++ -g which triggers my …

c++ c assert
How to assert an actual value against 2 or more expected values?

I'm testing a method to see if it returns the correct string. This string is made up of a lot …

java unit-testing junit assert