unit-testing

Rx Reactive extensions: Unit testing with FromAsyncPattern

The Reactive Extensions have a sexy little hook to simplify calling async methods: var func = Observable.FromAsyncPattern<InType, OutType>( myWcfService.BeginDoStuff, myWcfService.EndDoStuff); func(inData).ObserveOnDispatcher().Subscribe(x => Foo(x)); I am using this in an WPF project, and it works great at runtime. Unfortunat...

Interesting / well written unit tests to read (literate programming)

Do you know any open software projects that had particularly interesting / well written unit tests ? Writing unit tests often feels odd to me, because it seems either too random, too dense, to sparse, .. It would be great to read some real world examples (rather than books, library example code etc).. ...

starting and stopping hsqldb from unit tests

I'm trying to create integration tests using hsqldb in an in memory mode. At the moment, I have to start the hsqldb server from the command line before running the unit tests. I would like to be able to be able to control the hsqldb server from my integration tests. I can't seem to get this to all work out though from code. Thanks, Case...

Global.asax for Unit Tests?

In my MSTest UnitTest project, before running any tests, I need to execute some commands. Is there a feature, kind of like Global.asax is for web based projects, that will let me kick off something before any tests run? I should make it clear that when I say "execute some commands", I don't mean DOS commands, but execute some code. ...

Can I ensure all tests contain an assertion in test/unit?

With test/unit, and minitest, is it possible to fail any test that doesn't contain an assertion, or would monkey-patching be required (for example, checking if the assertion count increased after each test was executed)? Background: I shouldn't write unit tests without assertions - at a minimum, I should use assert_nothing_raised if I'm...

MSTest in Express editions of Visual Studio 2010

I'm leaning toward using MSTest as unit testing framework for a new project but I'm concerned with cutting off developers (maybe even myself in the future and/or in some specific environment) using Express editions of Visual Studio. I know MSTest wasn't available in VS2008 Express but with Microsoft pushing unit testing in recent years ...

Is it possible to unit test methods that rely on NHibernate Detached Criteria?

I have tried to use Moq to unit test a method on a repository that uses the DetachedCriteria class. But I come up against a problem whereby I cannot actually mock the internal Criteria object that is built inside. Is there any way to mock detached criteria? Test Method [Test] [Category("UnitTest")] public void F...

Test assertions for tuples with floats

I have a function that returns a tuple that, among others, contains a float value. Usually I use assertAlmostEquals to compare those, but this does not work with tuples. Also, the tuple contains other data-types as well. Currently I am asserting every element of the tuple individually, but that gets too much for a list of such tuples. Is...

Stubbing a before_filter with RSpec

Guys, I'm having trouble understanding why I can't seem to stub this controller method :load_user, since all of my tests fail if I change the actual implementation of :load_user to not return and instance of @user. Can anybody see why my stub (controller.stub!(:load_user).and_return(@user)) seems to fail to actually get called when ...

Stop unit tests from running

I would like to prevent all subsequent unit tests from running when certain conditions are met in a unit test. Is this possible in Visual Studio 2005? ...

Need an advice for unit testing using mock object

Hi there, I just recently read about "Mocking objects" for unit testing and currently I'm having a difficulties implementing this approach in my application. Please let me explain my problem. I have a User model class, which is dependent on 2 data sources (database and facebook web service). The controller class simply use this User mo...

Unit testing the decorator pattern

I recently solved one of my problems using the decorator pattern. Everything works fine and everything is decoupled enough (or so I think) that I am able to unit test each validitable field separately. My question is, if the NameValidator and AgeValidator both pass the tests for the Validate() and IsValid() (abstract) functions. Do I st...

populating in memory hsqldb database from script

Is there a way that I can specify a script in the connection string pointing to my in memory hsqldb instance? I was looking at this article and it looks like it is possible, but I'm not sure how to formulate the string correctly or where to put the script file. Looking at the hsqldb documentation here it doesn't appear to be the case. ...

DomDocument::loadHTML() error during phpunit test execution

I am currently trying to write some unit test against my zend framework controller. When I run the following code I receive this error: public function testListActionShouldContainListTable() { $this->loginToSystem(); $uri = $this->_uriBase . 'campaign/list'; $_SERVER["REQUEST_URI"] = $uri; $this->...

When transactionManager is not named "transactionManager" ...

I am trying Spring 3(.0.2.RELEASE) and JPA2 and Hibernate 3.5.1-Final... One thing upsets me is that spring seems only accept a transaction Manager named "transactionManager" If I don't name it "transactionManager" , Spring will throws NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined. Here is my config : <c...

Ruby testing: printing inside a test case

I'm brand new to Ruby testing and Google isn't helping. Using Test/Unit, how can I print an instance variable, like test "thing to happen" do do_stuff assert_equal "foo", @variable p @varible end ...

tools for testing vim plugins

I'm looking for some tools for testing vim scripts. Either vim scripts that do unit/functional testing, or classes for some other library (eg Python's unittest module) that make it convenient to run vim with parameters that cause it to do some tests on its environment, and determine from the output whether or not a given test passed....

Why are my RSpec specs running twice?

I have the following RSpec (1.3.0) task defined in my Rakefile: require 'spec/rake/spectask' Spec::Rake::SpecTask.new(:spec) do |spec| spec.libs << 'lib' << 'spec' spec.spec_files = FileList['spec/**/*_spec.rb'] end I have the following in spec/spec_helper.rb: require 'rubygems' require 'spec' require 'spec/autorun' require 'rack...

Testing a Generic Class

More than a question, per se, this is an attempt to compare notes with other people. I wrote a generic History class that emulates the functionality of a browser's history. I am trying to wrap my head around how far to go when writing unit tests for it. I am using NUnit. Please share your testing approaches below. The full code for the ...

Unit testing JSPs

Hi, I would like to ask you what technologies exist out there for creating unit tests for JSPs. I am already aware of the HtmlUnit/HttpUnit/JWebUnit/Selenium possibilities. Thank you! ...