unit-testing

Unittesting Corba in Python.

Hi there, I am interested in your opinions on unittesting code that uses Corba to communicate with a server. Would you mock the Corba objects? In Python that's sort of a pain in the ass because all the methods of Corba objects are loaded dynamically. So you're basically stuck with "mock anything". Thanks! Note: I believe I have not m...

Which objects to mock when doing TDD

When creating methods, should every object instantiated inside that method be passed in as a parameter so that those objects can be mocked in our unit tests? We have a lot of methods here at work that have no associated unit tests and upon writing tests retrospectively; we find that there are quite a lot of objects instantiated inside t...

How test SqlParameter for equality

Using NUnit and NMock2 I was not able to compare what I thought were the same SqlParameters: SqlParameter param1 = new SqlParameter("@Id", 1); SqlParameter param2 = new SqlParameter("@Id", 1); Assert.IsTrue(param1.Equals(param2)); // This failed I stumbled across this problem, when trying to test an execution of a method using NMock2...

Correct Approach for Unit Testing Complex Interactions

Hey, I had to start writing some unit tests, using QualityTools.UnitTestFramework, for a web service layer we have developed, when my approach seemed to be incorrect from the beginning. It seems that unit tests should be able to run in any order and not rely on other tests. My initial thought was to have the something similar to the f...

Unit Testing with the Mediator Pattern - All Private to Public

I am using the mediator pattern to facilitate unit testing of GUI objects. psudo code Example: Class MyGuiClass { //... Declare and initialize mediator to be a MyMediator private void On_SomeButtonPressed() { mediator.SomeButtonWasPressed(); } } Class MyMeditator { public void On_SomeButtonPressed() { //.. Do so...

Rhino Mocks - Stub a Singleton

I have a Singleton that is accessed in my class via a static property like this:OtherClassNotBeingTested.Instance.SomeInstanceMethod() I would like to test my class with out making one of these objects. Is there a way for RhinoMocks to return a stub when the getter for the static property Instance is called? To be clearer, here is the...

trouble executing Selenium python unittests in C# with ScriptEngine (.NET 3.5)

Hello all, first time poster. I'm turning to my first question on stack overflow because I've found little resources in trying to find an answer. I'm looking to execute Selenium python tests from a C# application. I don't want to have to compile the C# Selenium tests each time; I want to take advantage of IronPython scripting for dyna...

Selenium: Dynamic buttons and classes?

So, I was trying out a test case on a website and Selenium registers the events perfectly. Now, if I have to search for a particular class and get the innerHTML of that class, how would I do it assuming that I am using Java as the driving language? Just to be more clear. I have a class like this: <h1 class="classname">.....</h1> I...

Achieving unit testability of Presenter while using CSLA Framework with WCSF

The WCSF uses Model View Presenter (MVP) pattern for organizing/structuring the source code for a website. When MVP pattern is used correctly, it provides seperation of concerns, unit testability of presenter logic, etc. How to make WCSF and CSLA framework play well (work together) for achieving unit testability of the presenter logic. ...

How to implement SimpleTest in Kohana

Here's the problem, I was assigned task from my bos to learn how to use Kohana and implement simple test in that. We would like to use it as our framework for future projects. Being new to both KohanaPHP and SimpleTest, I can't figure it out how to do even the simplest test of my helpers. I can't even find a single step-by-step tutorial...

Error: Compilation Lock when running unit tests

We have over 1000 unit tests. A while ago 18 of them started to fail when they were run together with the other tests. These tests run a windows workflow. If they are run alone they pass. The error appears to be that it cannot find the connection string. It cannot find the connection string because it does not know which config file...

MOQ - Have a moq valid only once.

This is my problem test: [Test] public void PlayerHasPointsIncreasedOnEnterByFifteen() { // Arrange. var playerOneFake = new Mock<IEntity>(); playerOneFake.SetupGet(p => p.Score).Returns(0); var pointState = new PointState(playerOneFake.Object); // Act. pointState.Enter(); ...

MS Test - Access Private Property

I have a Private property that I want to access in my MS Test unit test. // Make a local property for control so that we can mock the control object. private Control localControl { get{return Control.Instance;} } I go to that unit, right click and select Create Private Accessor->MyUnitTestProject The status ba...

Ruby on Rails with Repository Pattern?

After working with ASP.Net MVC, it has me thinking about Rails. I worked with Rails prior, but am a little rusty. ASP.Net MVC tutorials recomment hiding data layer implementation with the repository pattern. This allows easiesr Dependency Injection for Unit Testing, and nice decoupling of the controller from the model implementation. ...

Visual Studio: Test ClassCleanup Timeout When Executing A Batch File

My aim is to restore an Oracle database back to it's previous state after a lot of unit tests have been run by using flashback recovery using the ClassCleanup attribute. I have written a batch file + SQL to properly restore the database. This has been tested in my command prompt numerous times without issues I would normally put the re...

Should every test method have at least one assert?

When I'm testing a void method there is nothing to assert.For example a CreateSomething method. I know I could call in the test method an other method like FindSomething,but anyway, if there is (in the create method) an error it will show up. So it's a good practice to call an assertion in every method or i'm fine sometimes without an as...

overloading __init__ of unittest.testcase

hi I want to add two variables to my subclass which is inherited from unittest.testcase like I have: import unittest class mrp_repair_test_case(unittest.TestCase): def __init__(self, a=None, b=None, methodName=['runTest']): unittest.TestCase.__init__(self) self.a= a self.b = b def t...

How to execute one test from large TestNG suite using testng.xml?

I have a TestNG suite with large amount of methods. I execute this suite using wrapper built on top of TestNG runner. All tests in the suite fail except one. What should I write in testng.xml to execute just that one failed test? Obvious solution is to assign unique group names to all of the methods and then specify name in testng.xml. ...

NLog with VS 2008 Unit Test

I am trying log some entries in a log file (Log.Trace / Log.Debug) while my VS unit test runs. I have also copied the file NLog.config to out directory through DeploymentItem attribute over class. Still my log file is not created. Any help as to how can we log entries in a file same as we do for normal web application. ...

Verifying contents of NHibernate Criteria

I'm looking to build complex queries using the NHibernate Criteria API. I'd like to verify that the criteria is constructed as I would expect without having to actually run the query. Is this possible? Are there any tips or techniques for doing it elegantly? ...