unit-testing

Rhino Mocking and TDD with legacy code

Hi, First of all let me say I am working from legacy code. So some changes can be made but not drastic ones. My problem is I have a "Vehicle" object, it is pretty simple but has no interfaces or anything on it. This project was created before TDD really started to become more main stream. Anyway, I need to add a new method to change th...

Rhino Mocks - Using Arg.Matches

Hi, I have a function I am mocking which takes an argument object as a parameter. I want to return a result based on the values in the object. I cannot compare the objects as Equals is not overriden. I have the following code: _tourDal.Stub(x => x.GetById(Arg<TourGet>.Matches(y => y.TourId == 2), null)).Return( new Tou...

ZF, ZFDoctrine and PHPUnit setup

Hi, Does anyone here use Zend Framework, ZFDoctrine and PHPUnit together? How to rebuild the database on each test run? How to separate local/production/testing environments? Would you share your unit testing setup? I have been trying something like that: // /tests/bootstrap.php // ... setup paths and constants here require_once 'Ze...

Automatic Unit Testing with NANT and VS2008 during build process

I'm using VS2008 Pro and as such my c# project includes a bunch of Unit Tests written in the MS bundled unit test framework (sorry I have no idea what its official name is!). I would like to be able to run these unit tests as part of my build process. Is it possible to get Nant to automatically run these Unit tests during a build? ...

Django: Test confusion

In the unit tests that I wrote, I provide a test fixture for each TestCase. However, I keep getting duplicate (IntegrityError) when it runs in the test suite. So, I am wondering, isn't the database supposed to be created and populated at the beginning of each TestCase and after each test has be executed in that TestCase so that I can p...

Tutorial for Unit Testing with VS 2010

Hi I am new in unit testing and need some book or tutorial. I have looked alot in google, but can't find anything. I saw this question, but there is no answer, that's why I am asking it too. Is there anything from which I can start? Thanks. ...

Is defining TestMethod's in test base classes not supported by MsTest?

This question concerns a general unit test technique with a potentially very useful wide range of applicable scenarios. But it is easier to understand with an example to illustrate my question better. Let's say I want to test that all types that override Equals() does so correctly. Since Equals() is defined as virtual in System.Object, ...

New Project with Web Client Software Factory

I want to start a new project basically a e-commerce website. I trying to figure out is there any advantage of using Web client software factory (WCSF) over creating all the layers by myself. How much time does it save me. What are the other failure associated with WCSF. ...

How do I have TestNG run tests in specific groups (from the command-line)?

I'm invoking TestNG from the command-line like this: java org.testng.TestNG -groups "foo" testng.xml ...with the intention of only running tests annotated with: @Test(groups = { "foo" }) ...but it's running all my tests. Do I need to change my testng.xml file? <suite name="BarSuite" verbose="1"> <test name="AllInPackage"> ...

How to check programmatically that Debug and Release builds of VS2010 use the exact same configuration?

We have a Visual Studio 2010 solution, with C#/C++/VB.Net as well as other projects. It is not MsBuild-based. My co-workers and I mostly work with Debug build, and Release is rarely used, but is used indeed (say that there is a Release-only bug; those do pop-up from time to time.) The nightly builds follow their own separate process, a...

JUnitCore run() method is not implicitly calling setUp() before each test.

I am creating a custom test runner for JUnit test cases using JUnitCore's run(junit.framework.Test test) and passing in ClassName.suite(). My tests run, however the results returned are null. It seems that objects are not being initialized in the setUp() method cause setUp() apparently is never called as it should, even with the @Before ...

Duplicate Output Problem with TestContext.WriteLine

I've made an "ordered test" in VS 2008 which executes 4 tests. One of the TestMethod tests it runs has several writeline statements, like this: TestContext.WriteLine("One"); TestContext.WriteLine("Two"); TestContext.WriteLine("Three"); The output I receive in the "Additional Information" of the results shows this output: One Two Thre...

Unit Testing in Qt with Highly Dependent Functions

I'm new to unit testing. I want to code unit tests in Qt, but my functions(login, request etc...) heavily depend on other resources such as a server. How can I supply a block box in this situation? Do you know any open source project which I can examine unit test classes for similar situations? ...

C# Unit Test error, could not load file or assembly when running test

I'm working on a unit test in a project using the MOQ-framework, C# 4.0, MVC2.0 The test is similar to the one below. But as soon as i run this test i'm getting a strange error. I've checked all the referenced System.Web.mvc assemblies and there all at version 2.0.0, so it seems to me that those can't cause the issue. [TestMethod] ...

[PHP] UnitTests fail, manual test passes

Hi, There is something weird going on in my code so i have to ask. I have a part of a test: public function testGetAddresses() { //$this->markTestIncomplete('Not implemented yet'); $this->assertTrue($this->_prs->getAddresses() instanceof Crm_Collection); } This test fails. But when I do this: if ($entity->getAddresses() in...

django-nose testrunner doesn't use --with-django option

When running nosetests, django-nose runner doesn't supply --with-django option to nosetests, so my nose + Twill tests fail when trying to access URLs: ./manage.py test ... raise BrowserStateError("cannot go to '%s'" % (url,)) BrowserStateError: cannot go to 'http://127.0.0.1:8088/admin/' -------------------------------------------------...

How to handle type and input into WYSWYG editor such as tinymce when testing using selenium RC?

is there any solution to this problem i use : $this->type('contentform', 'i need to print this and go on with my testing'); but after i do submit it failed while when i do it manually it work. i'm using this code for submit: $this->click("publish"); i test my app via selenium RC + phpunit ps: it work in selenium IDE but fai...

ASP.NET MVC Unit Testing and HttpContext

ASP.NET MVC has come a long way (compared to webforms) in becoming a unit testable framework. However, we are often faced with some remaining pigs like FormsAuthentication, which I usually wrap in some type of UserSession object to keep it clean and testable. The other day I realized I was using Server.MapPath in my controller action, an...

VisualStudio unit test doesn't find my DLL with P/Invoke. How can I fix this?

Hello, I'm working on Windows 7 with Visual Studio 2008. I have a .NET assembly that makes calls into a native DLL with P/Invoke. I have set up a separate .NET unit test project in my Visual Studio solution that tests the assembly by making various calls into it. However, when the unit test makes a call into the assembly, and the ass...

Equivalent of assertRegexMatches in python 2.4

Hi ! Say I have a regex REGEX = re.compile('.*foo{') How would you write a unit test that matches a set of string with python 2.4 ? I know in python 2.7 I can use assertRegexMatches, unfortunately this doesn't work in 2.4 :/ I use self.assertEqual for the rest of my tests. Cheers, M ...