unit-testing

Getting Error "Cannot start more than one local run" in Unit Tests in Visual Studio

I am executing a Test to Automatically start my Windows Application. To lauch the Windows Application; the Code used is "Application.Run(Client.MainForm.GetInstance())";. The Debug point comes out of this piece of Code only after i close the Windows Application. I cannot run any other tests until then. If i try to do so; Visual Studio t...

Unit test helper methods?

Hi, I have classes which prviously had massive methods so i subdivided the work of this method into 'helper' methods. These helper methods are declared private to enforce encapsulation - however I want to unit test the big public methods, is it good to unit test the helper methods too as if one of them fail the public method that calls i...

How to catch AssertPathsEqual and print error to console?

How could I catch this AssertionFailedError and print to the console an message that says: "Expected text value '55555' but was '55556' at /xpathResult[1]/result[2]/field[1]/field[1]/field[6]/text()[1] for [testFileName] and [testName]" I'm not exactly sure how to catch the values out from the assertion without having to "hack" and man...

Upgrading to JUnit4 and keeping legacy JUnit 3 tests and test suites by running them together

I was surprised not to find the answer so far. If I am missing something basic I will be more than happy to know that. There is a large legacy code base that was upgraded to Java 6 (from 1.4). Large number of JUnit 3 tests are present in the code and are organized into test suite that runs successfully with JUnit 4 default runner in Ecl...

Unit Testing DAL - Stop Connecting when running unit tests.

I am unit testing a DAL (Data Access Layer). When I debug a unit test, before my unit test constructor is even run, Visual Studio fires up WcfSvcHost. Why is it doing that? I am mocking out everything so I can just test what little logic there is in my DAL. I don't want it to do anything but run my unit test. Any ideas on how to t...

How to unit tests functions which return results asyncronously in XCode?

I have something like - (void)getData:(SomeParameter*)param { // Remotely call out for data returned asynchronously // returns data via a delegate method } - (void)handleDataDelegateMethod:(NSData*)data { // Handle returned data } I want to write a unit test for this, how can I do something better than NSData* returnedDat...

How can I run many test cases for a test method

I'm using JUnit.I have a test method to test a method and some test cases. I want to run all tes case in that test method, but I can't do that. When first test case fail, test method don't run second test case Here is my code public class ComputeServiceTest extends TestCase { //test add method public void testAdd() { ComputeServices ...

When creating a custom Toolkit, why does createFrame fail on OSX?

We are trying to extend the UISpec4j testing framework to display the user interface when running tests. So we have a custom toolkit that wraps around the native toolkit for the relevant platform. We managed to get everything working well on windows XP, however when testing our changes on OSX, our extension of createFrame appears to beha...

Where do I store MVC/MVP and Service layer unit tests?

In MVC/MVP style applications that have Controller/Presenter classes within the Client Application assembly and then a Services layer assembly containing Service classes, where do people recommend storing their unit tests? For ease of execution it'd be nice to have a single Test assembly that references both the Client and Services, and...

VS2008 Unit Tests: Order of Execution

Folks, My apologies for the novice question. It's probably obvious, please don't laugh :-) I have unit tests defined for my Visual Studio 2008 solution. These tests are defined in multiple methods, in multiple classes across several files. I've read in a blog article that depending on the order of execution of tests is wrong; that ...

How can I invoke assertXXX manytimes using setUp() and tearDown()

I'm using JUnit. I want to invoke assertEquals() many times in a test method to test many diferent test cases but I don't want to have many test method. So I use setUp() and tearDown(). But when the first assertEquals() fail.The second assertEquals()doesn't work and setUp() method just have been invoked one time. Here is my code public...

How do you create an echoing mock using Moq?

I am creating a mock for my ITransformer interface. public interface ITransformer { String Transform( String input ); } I can create a mock that returns an given string based on a specific input: var mock = new Mock<ITransformer>(); mock.Setup(s => s.Transform("foo")).Returns("bar"); What I would like to do is create a mock wit...

How to test soft deletion event listner without setting up NHibernate Sessions

I have overridden the default NHibernate DefaultDeleteEventListener according to this source: http://nhforge.org/blogs/nhibernate/archive/2008/09/06/soft-deletes.aspx so I have protected override void DeleteEntity( IEventSource session, object entity, EntityEntry entityEntry, bool isCascadeDeleteEnable...

Replacing a function definition in C

Possible Duplicate: What is the best solution to replace a new memory allocator in an existing code? I'm writing a library in C. I'd like to know if there is a way to divert every malloc() call my library makes to a different "augmented" testmalloc() function that I provide without (significantly) modifying my library. This qu...

Shoulda tests failing on model with no id

I created a new model in my rails app. Since it's a one-to-one relation with another table, there's no need for the new model to have an id column. Everything is working fine, but for some reason, all of my Shoulda tests on this model are failing. For example: should_validate_presence_of :first_name is throwing this error: ActiveR...

Grails PUT request with XML

I have a put request that I am trying to unit test for creating a user object. Unit Test: void testPUTXMLResponse() { def mockUser = new User(username:"fred", password:User.encrypt("letmein"), firstName:"Fred", lastName:"Flintstone", middleName:"T", phone:"555-555-5555", email:'[email protected]', activationDate:new Date(), logonFai...

unit tests for screen-scraping?

I'm new to unit testing so I'd like to get the opinion of some who are a little more clued-in. I need to write some screen-scraping code shortly. The target system is a web ui where there'll be copious HTML parsing and similar volatile goodness involved. I'll never be notified of any changes by the target system (e.g. they put a redes...

Testing with Thread.sleep

What are the recommended approaches to using Thread.sleep() to speed up tests. I am testing a network library with a retry functionality when connections are dropped or timeout errors occur, etc. The library however, uses a Thread.sleep() between the retries (so it won't connect thousands times while the server is restarting). The cal...

Should I document my unit test methods?

As it happens with private methods, unit test methods documentation can only be seen by who has access to the source code. Is it worth the effort spent on it? By documentation I mean something like (but more descriptive): /// <summary> ///A test for SomeClass.SomeMethod ///</summary> [TestMethod()] public void SomeMethodTest() { } ...

Calling $(document).ready(function() {...}); from another file

Hi all: As the title suggested, I'm trying to call the $(document).ready(function() {...}); from another file. The code snippet is as below: Source file: $(document).ready(function () { alert('document.ready function called!'); // a lot of code } And in the test file: TestFile.prototype.testDocumentReadyContents = function...