unit-testing

Django unittests: The model is already registered Error

Hi! I come across several problems while trying django unittests library. Something strange happens: I defined the test like this: from django.core import management from django.test import TestCase from django.test.client import Client from django.core import mail from django.test.utils import setup_test_environment from django.contr...

Inflections seem to not get loaded in test environment of a rails app

I have a model named Aggelia (it's greek for classified ad) and have set an inflection in RAILS_ROOT/config/initializers/inflections.rb like so: ActiveSupport::Inflector.inflections do |inflect| inflect.irregular 'aggelia', 'aggelies' end It works fine in the development environment but when I try to run the tests (only assert truth...

Visual Studio error while creating Unit Tests

I want to create unit tests for one of my project's classes but I'm getting a following error when I right click on the class source code and choose Create Unit Tests button: The following error was encountered while reading module 'Microsoft.Office.Tools.Common.v9.0': Could not resolve type reference: [office]Microsoft.Office.Core.I...

Testing controller Action that uses User.Identity.Name

Hello, I have an action that relies on User.Identity.Name to get the username of the current user to get a list of his orders: public ActionResult XLineas() { ViewData["Filtre"] = _options.Filtre; ViewData["NomesPendents"] = _options.NomesPendents; return View(_repository.ObteLiniesPedido(User.Identity.Name,_...

How to use Rhino Mock to mock a local function calling?

Here is my situation: I want to test on the "HasSomething()" function, which is in the following class: public class Something { private object _thing; public virtual bool HasSomething() { if (HasSomething(_thing)) return true; return false; } public virtual bool HasSom...

Rails batch object creation for fixture?

I have a big list of record (something like 20, could be more) with a has_many :through relations, which is a bit complicate and it looks ugly on yml. Factory_girl doesn't seems to give me the simplistic ability to just create the fixture with a AR based script (it's a lot shorter that way) any good recommendation on what I could do? ...

TDD: Adding a method to test state

So, I'm starting to write some logic for a simple program (toy game on the side). You have a specific ship (called a setup) that is a ship + modules. You start with an empty setup based off a ship and then add modules to that setup. Ships also have a numbered array of module positions. var setup = new Setup(ship); // ship is a stub (...

Unit Testing, Linq to SQL and working around the Data Context

Hi guys I have been looking at the following and it would appear that there are great benefits to be gained by using compiled queries... http://blogs.msdn.com/ricom/archive/2008/01/14/performance-quiz-13-linq-to-sql-compiled-query-cost-solution.aspx My problem is that I want to unit test my queries, but compiled queries need a concre...

What are the best practices regarding unit testing a library/framework ?

Context I'm struggling to write a set of unit-tests for a library/framework I'm designing. For context, please, think of my library as an object layer over a hierarchical set of related objects. Question Basically, I'm trying to adhere to the principles and best practices regarding unit testing as seen in some posts here, but they see...

Asserting the last record in table

I'm trying to assert that the last record did not get deleted in rails model unit test. I raise an exception if the record.count.one? is true. Initially there are two records. Edited: There is a user story that says you can delete the users. You cannot delete the user that you are logged in with. (functional test) You cannot delete the ...

Testing NHibernate CRUD Operations

Hi I'm testing some CRUD operations in Nhibernate. I have 3 tests in this order - add update and delete. When I test the update procedure I always get a fail as the object I just added is null. Do I need to close the session or do a flush before doing the update test. Or is there a better way for me to do this. Any help more than appre...

Is there an AssertEquals for testing XML files?

I have frequent need to test that XML files are correct and need a way of testing that 2 XML strings (or documents) are identical, such as: XMLAssert.assertEquals(String xmlExpected, String xmlActual); In addition it would be useful to show where the xml documents differed. This should be restricted to documents with standalone="yes...

How to unittest ejb 2 classes

What kind of tools and techniques exist for this purpose? ...

How to unit-test logic in jsp?

What kind of tools or techniques exist for this purpose? ...

Switching from MSTest to another unit test framework in VS 2010

Hi, Visual Studio 2010 offers a lot of comfortable tools for unit testing via its built in test runner. Unfortunately we can't use MSTest for our unmanaged c++ codebase. Is it possible to switch from MSTest to e.g. Google.Test and have it integrated with the built in Visual Studio test runner? Thanks in advance! ...

Is there a way to get/save the DOM with Selenium ?

What I'm looking for is a method that works like "captureScreenshot(String path)", but instead of producing an image is saves the DOM as it currently is. Note that the existing getBodyText() method is not enough. ...

Using Moq, how do I verify all properties of an object were copied?

I have an interface with a CopyFrom() method that copies all properties from another object. I have a test that performs several VerifyGet() calls to ensure that each property was retrieved from the passed object, e.g.: Thing target = new Thing(); IThing source = new Mock<IThing>(); target.CopyFrom(source.Object); source.VerifyGet(t =...

Using Maven to build separate JAR files for unit testing a custom class loader

As part of my current project I've created a custom class loader. Part of the unit tests for the custom loader involves using some JAR files to demonstrate the proper behavior of the loader. I'd like to build the test JAR files from Java sources ahead of running the actual unit tests. Further, the test JAR files cannot be on the class p...

How to make fixtures updateable in Rails' tests?

Below I listed some code from simple Rails application. The test listed below fails in last line, because the updated_at field of the post is not changed within the update action of PostController in this test. Why? This behaviour seems to me a little strange, because standard timestamps are included in Post model, live testing on local...

ABAP Unit Test Classes - Good References

I'm looking for good reference material regarding the use of ABAP Unit Test Classes. I'm interested in any of the following: Documentation on the functionality Best Practises "How To Guides" Blogs/Books on people's experience in using test-driven development in a SAP environment, particularly what sort of scenarios leans themselves to...