assertions

having javascript force a Selenium test to fail

Is there a way for js code to force Selenium testing to fail? For (a probably bad) example, if I had the following: return document.getElementById('foo').innerHTML == 'hello' is there a way I could make the 'runScript' command fail depending on if the js code returned true or false? (I know that example could be used by other Selenium...

What does this code in "vector" mean? (C++)

I created a program, and it uses the vector.h #include, and iterators, etc... But when I run the program, under certain circumstances (I'm still trying to figure out what those would be) I get an assertion error refering me to line 98 of vector.h. I went to line 98 of vector.h and got this: #if _HAS_ITERATOR_DEBUGGING if (this->_...

Asserting in NUnit that a collection is in the same order as an expected collection

I know how to check that a collection is ordered by some property: Assert.That(actual, Is.Ordered.By("Foo")); How can I assert that actual contains the elements (1,2,5,3,4) in this specific order (without writing a custom comparer). ...

Fully Featured C++ Assert Dialog?

Hi, I'm looking for a good, fully featured C++ assert macro for VisualStudio. With features like be able to ignore an assert once or always, to be able to break exactly where the macro gets called (and not inside macro code), and getting a stack trace. Before I have to hunker down and write one, I figured I'd ask if anyone knows about ...

Is there an easier way than using #ifdef in C?

From what I understand assert is a macro in C and supposedly if you use it at compile time but leave it disabled then there won't be overhead (which might not be correct I don't know). The problem for me is that what I'd like to do is get all the variables passed to my function and print out that output, but only if I want debugging enab...

How can I have variable assertions in Perl?

How can I check that a variable has a specific value in Perl? Is there a command to stop a script's execution to look up some of it's variables? I wonder if I can use the Pythonic practice of inserting: assert 0, (foo, bar) to debug scripts in a debuger-less way? ...

ExpectedException in jUnit?

Is there an equivalent to NUnit's ExpectedException or Assert.Throws<> in jUnit? ...

Mixed mode MFC application not intializing correctly in VS2008

I have converted a mixed mode MFC application from VS2005 to VS2008. It is compiling OK but when starting the application I get an assert in afxwin1.inl because afxCurrentResourceHandle = NULL. This is before MyCWinApp::InitInstance is called. The call stack is mfc90d.dll->AfxWinInit (with HINSTANCE = NULL) myapp.exe!InternalDllMain my...

Why should I use asserts?

I never got the idea of asserts -- why should you ever use them? I mean, let's say I were a formula driver and all the asserts were things like security belt, helmet, etc. The tests (in debug) were all okay, but now we want to do racing (release)! Should we drop all security, because there were no issues while testing? I will never...

CollectionAssert in jUnit?

Is there a jUnit parallel to NUnit's CollectionAssert? ...

Debug Assertion Failed ... _BLOCK_TYPE_IS_VALID (pHead ...

I am getting this error message while trying to do the following #include <vector> #include <algorithm> using namespace std; class NN { public: NN(const int numLayers,const int *lSz,const int AFT,const int OAF,const double initWtMag,const int UEW,const double *extInitWt); double sse; bool operator < (const NN &net) const {r...

Is assert and unit-testing incompatible?

Hello, I have some concerns related to the fact of testing some functions containing the assert macro from assert.h. If the assert fails the test fails also. This leaves me with some test cases that will never work. For example a function instead of indicating failure (return false or something similar) asserts. Is there a solution f...

java assert gives strange results

what should the following java code do? public class foo{ public static void main(String[] args){ boolean mybool=false; assert (mybool==true); } } Should this throw an assertion error? and if not why not? (I'm not getting any errors!) ...

Should one override equals method for asserting the object equality in a unit test?

Let's say we are testing the result of a method by asserting the equality of all the properties of the result object with properties of an expected result object. Should we implement equals method and use Assert.AreEqual(expectedResult, actualResult)... But equals may mean something different in production code. Which is the best prac...

Do you use assertions?

This is not really a "question" so I'm making it CW. The assert Keyword is great! It should make, feel your self more confident with the code you wrote, but, until today when I was creating a small test class ( < 20 lines ) I realize a never use it since it was introduced. Heck! I barely use logger which is very useful indeed, ...

.Net equivalent to Java's AssertionError

In Java, I will occasionally throw an AssertionError directly, to assert that a particular line will not be reached. An example of this would be to assert that the default case in a switch statement cannot be reached (see this JavaSpecialists page for an example). I would like to use a similar mechanism in .Net. Is there an equivalent ...

RegexKitLite assertion failure occurring intermittently.

I'm using the wonderful RegexKitLite framework built upon the ICU library that ships with Mac OS X and iPhone OS. It has been smooth sailing so far, with the exception of this error that appears intermittently when searching for matches: Internal Error Invalid parameter not satisfying: (cacheSlot->setToHash == buffer->hash) && (cacheSlo...

Best way for testing compiled code to return expected output/errors

How do you test if compiled code returns the expected output or fails as expected? I have worked out a working example below, but it is not easily extendable. Every additional test would require additional nesting parentheses. Of course I could split this into other files, but do you have any suggestions on how to improve this?. Also I...

Unit testing: Is it a good practice to have assertions in setup methods?

In unit testing, the setup method is used to create the objects needed for testing. In those setup methods, I like using assertions: I know what values I want to see in those objects, and I like to document that knowledge via an assertion. In a recent post on unit tests calling other unit tests here on stackoverflow, the general feelin...

Is GNU's nana library dead? Is there a successor in use?

Looking at http://savannah.gnu.org/projects/nana/ it seems that the last work was done on Nana four years ago, and the official gnu.org homepage for nana is a placeholder. Given how inactive projects tend to suffer from bitrot: Has the project died? Is there a successor? Do folks have a different assertion/logging library for C/C++ ...