unit-testing

How do I disable rescue handlers in Ruby on Rails apps when I'm running functional tests?

I have a number of controllers in my Ruby on Rails apps with a rescue handler at the end of the action that basically catches any unhandled errors and returns some kind of "user friendly" error. However, when I'm doing rake test I'd like to have those default rescue handlers disabled so I can see the full error & stack trace. Is there an...

Is it worth the effort to write tests that work with the browser (like using selenium or something)?

It's pretty clearly worth it to write tests for stuff that happens on the server side, but I've heard that it is really hard to write unit test for UI stuff and that they are fragile and unreliable. I would love to have more confidence that changes that I make don't break major parts of import pages on my site though. Any thoughts or e...

I need a sample of python unit testing sqlalchemy model with nose

Can someone show me how to write unit tests for sqlalchemy model I created using nose. I just need one simple example. Thanks. ...

How to make a .NET process run out of memory without exhausting all system memory.

The problem is simple I have a process, that does ETL on some xml files. We started getting really large xml files and I started getting OutOfMemoryExceptions. Fixing the process is relatively simple. However, I'd like to make a unit test for my NUnit suite to make sure the process will continue to be able to handle really large files. ...

JUnit theory for hashCode/equals contract

The following class serve as generic tester for equals/hashCode contract. It is a part of a home grown testing framework. What do you think about? How can I (strong) test this class? It is a good use of Junit theories? The class: @Ignore @RunWith(Theories.class) public abstract class ObjectTest { // For any non-null refere...

Hashmap in the making

How to go about creating a Hashmap in C from scratch ? What would be the parameters taken into consideration and what how would you test the hashmap as to how good it is ? As in what would be benchmark test cases which you require to run before you say that your hash map is complete. ...

Schema validation difference between BizTalk IDE and XmlReader

I'm trying to get into unit tests for a BizTalk application I'm working on, following the example in Michael Stephensons blog post and seemed to be getting somewhere Then I got an error down the line, which I tracked back to a "invalid" XML test file I was using, but this was passing my validation against schema unit test ... - reason ...

What is unit testing?

I have read dozens and dozens about unit testing, and believe that I have learned through context only what a unit test is, but I want to be sure that I am right. What follows is my understanding of what a unit test is. Please correct this statement: "A unit test is a method that provides known arguments to the method being tested, an...

Using TSQLUNIT for SQL unit testing: don't you need to duplicate your SQL code?

Hi, I'm considering writing some unit tests for my Tsql stored procedures, I have two concerns: 1) I will have to write a lot of SQL to create test fixtures (test data prepared in _setup procedures) 2) I will have to "re-write" my query in the test procedure to obtain the results to compare against the results from the stored procedure...

Creating a mock with Jmock to return a null value for itself

I have a method that looks similar to the following: public void myMethod(MyClass c) { if (c == null) { return; } try { c.someMethod(); } catch (SomeException e) { // log the exception, possibly re-throw } } I am trying to find a way to set up a mock instance of the MyClass parameter c such that it return...

PHP language (unit) tests

At the moment I am working (just for fun) on a kind of compiler that breaks PHP-code down to a source code for a low level VM. As the type system and a lot of of the PHP-features are not that logical I need a much testscripts to verify that my code behaves as it would in PHP. I started to test everything with the test from the PHP-sour...

FluentNhibernate and SQLite

Hi, I can't get SQLite Driver working in my sessionfactory. I downloaded SQLite 1.0.48 from http://sqlite.phxsoftware.com/ I have added the references to System.Data.SQLite in my Tests project. public static IPersistenceConfigurer GetSqlLiteConfigurer() { try { return SQLiteConfiguratio...

Unit tests for automatically generated code: automatic or manual?

I know similar questions have been asked before but they don't really have the information I'm looking for - I'm not asking about the mechanics of how to generate unit tests, but whether it's a good idea. I've written a module in Python which contains objects representing physical constants and units of measurement. A lot of the units ...

C# testing -- why does ExpectedException tagged method pass when exception not thrown?

In the past I have tested for expected exceptions like this: [TestMethod] public void TestThrowsException() { try { Foo(); Assert.Fail(); } catch (MyException ex){//good } } However I notice that there is a (cleaner?) way to test this using the ExpectedException attribute. Why does this test method pass when the exceptio...

Unit Testing Procedures (As opposed to functions)

I am new to unit testing, and would like to know how you would go about unit testing a procedure (in this case a procedure a function that "does something" rather than "return something". I know that the general idea of testing a function that returns an answer is something like assert(yourfunction(sample, inputs) == expected_answer);...

will a mocked interface still serialize to a file?

I'm trying to unit test saving of a file. I have an interface that defines a document, and I pass a concrete object that implements that interface to the Save method, and it works in practice, but I'm trying to unit test it to ensure that it will always work (and I'm desperately trying to catch up on the unit tests after a period of 'cru...

Recommended Unit Testing Book for an ASP.NET MVC environment

I need recommendations on a good Unit Testing book for use with ASP.NET MVC. Based on books you have actually read and use (your bible), what do you recommend? ...

Automated Testing: ways to help and educate developers?

I'm a software test engineer embedded in a development team. A large part of my job involves checking over the state of the project's automated tests (mainly unit/integration tests). I'm not a short-sighted zealot who wants to force testing down everyone's throats, but I do want to help everyone to get the best out of the time they spe...

Test framework for [insert language here]

I am looking for a test framework to introduce automated tests for a language without much test support. As far as I can understand, I need a framework that's capable of running the VDF tests using some form of protocol. I would much rather spend my time writing tests than writing VDF code to interface with the test framework, so a light...

How to write unit tests for SerialPort

I know the short answer is Mocks, but any examples would be good. I need to be able to test the following: 1. Connect/disconnect 2. Receive data at set intervals 3. Pause in data transmission, causing my class to attempt reconnect 4. Test that events are firing when expected. As a start, I was thinking of defining an interface, which w...