unit-testing

MS Unit Testing in VS 2010, Test Method [my method] threw an exception: ..., WT*?

Hi, I've got an ASP.NET MVC 2 Web app in VS 2010 and decided to try using MS unit testing stuff. What do you know, on the first test I created it gives me grief and refuses to elaborate. I have created a single test class and a single test method. I am using Moq to create a HttpContext (including Request, Response, Session, QueryString...

It is possible/productive enough to TDD in C++ projects?

Hello guys, I want to know if anyone of you guys use TDD in your c++ projects and how it performs compared to managed languages like C# and Java. And what frameworks you guys are using to automate tests on c++ projects? ...

Run scala unit test from command line separately with Maven

Well, Maven is too good, when talking about speed. But I want something that is more acceptable. Imagine I wrote a test org.fun.AbcTestCase In such TestCase, I include some JUnit / TestNG tests Now I want to run only this test case, said org.fun.AbcTestCase from command line. How can I do that? I know it's easy to do it within Eclipse o...

XCode and SenTestingKit not outputting to the editor window

I am new to testing in Xcode. I am following the developer documentation "iOS Developement Guide" Unit Testing Applications. I have successfully added unit test bundles to my application with one failing test. When I build the test target the output shows 1 error as expected but the editor does not show the expected error message unde...

What's the best way to assert for scipy.array equality?

I want to make some unittests for my app, and I need to compare two arrays. Since array.__eq__ returns a new array (so TestCase.assertEqual fails), what is the best way to assert for equality? Currently I'm using self.assertTrue((arr1 == arr2).all()) but I don't really like it :\ ...

How do I bootstrap for unit testing with Zend MVC and Zend_Test?

I have read many posts about setting up unit testing in Zend Framework and I simply have not been able to get even one simple unit test to run. The issue is with setting up and testing the bootstrap environment. I tried the simplest of ways using the ZFW docs, but I always get this error: Zend_Config_Exception: parse_ini_file(/usr/l...

How do I test rendered views when using T4MVC with TestHelper?

How do I test which view was rendered from a controller action if what I get is a T4MVC_ActionResult? Under normal circumstances I should be able to directly use TestHelper's methods, like in the examples: pooController.Details().AssertViewRendered().ForView("Details") ...but, since through T4MVC I get a T4MVC_ActionResult instead of ...

Unit Test Problem with assertRaises

I am trying to test for an exception. I have: def test_set_catch_status_exception(self): mro = self.mro NEW_STATUS = 'No such status' self.assertRaises(ValueError,mro.setStatus(NEW_STATUS)) I get the following error: ====================================================================== ERROR: test_set_catch_status_excep...

When running a unit test on the controller save method, for some reason a grails models save method returns simply null.

So we have a unit test which is failing where we attempt to call the save method on a model. This for some reason returns true when we run the method in reality. We've mocked the domain in the setUp method. Does anyone know why the heck the save method is returning null? Source Code here: http://gist.github.com/485365 We're running Gr...

Unit testing and SAP

I am looking for some tutorials and guides for unit testing on SAP platform. So far, I have found some mention of ABAP Unit and of Ruby programming language being implemented on SAP platform, making it much more interesting option for unit testing SAP. However, the information is quite scarce and I would appreciate some help on the subj...

One for the NUnit gurus: Upgrading to 2.x and using new features with existing testing harnesses

I've recently upgraded to NUnit 2.5 (yeah I know) and I was wondering if I could pick someone's brain with this. I have lots of tests that look like this: [Test] public void TestTheSpecialDict() { int start = 0; int end = 44; Dictionary<int, string> = SomeFunction(start, end); Assert.That(dict1.Count > 0); // Alr...

Can I create a Stub of an Activity in Testing Project?

I want to create a stub of one of my Activities, but I want to keep it in the test project so not to have it in the actual apk. I don't seem to be able to find a way to do it though. I get this: java.lang.RuntimeException: Unable to resolve activity for: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.example.test.StubA...

Bringing unit testing to an existing project

I'm working on an existing JEE project with various maven modules that are developed in Eclipse, bundled together and deployed on JBoss using Java 1.6. I have the opportunity to prepare any framework and document how unit testing should be brought to the project. Can you offer any advice on... JUnit is where I expect to start, is this...

How can I specify the database password when running database unit tests during the build?

I'm trying to integrate database unit tests into the build process (Visual Studio 2005, TFS, VS for Database Professionals, MS SQL Server 2005). The build is running on a dedicated build server. When the tests (that work perfectly locally) start running on the server, I get a "login failed" error because the database password I save in T...

Unit testing a class that generates distinct strings

I'm trying to write a unit test for a class that generates distinct strings. My initial reaction was the following: public void GeneratedStringsShouldBeDistinct() { UniqueStringCreator stringCreator = new UniqueStringCreator(); HashSet<string> generatedStrings = new HashSet<string>(); string str; for (int i = 0; i < 10...

Adding Invariants to Interfaces in Java

I've been thinking about creating a Java framework that would allow programmers to specify invariants (pre- and post-conditions) on interfaces. The purpose would be to make code more robust and reduce the number of unit tests that would need to be written for different implementations of the same interface. I envisage creating some way ...

Structuremap and Unit Testing - Inject stub for ObjectFactory.GetNamedInstance

Hello, I am writing some unit tests for an MVC controller which requires a call to ObjectFactory.GetNamedInstance. The code looks as follows ObjectFactory.GetNamedInstance("BuyerMembershipProvider") I am aware of the ObjectFactory.inject method to Inject a stub of the desired type, however it does not seem to work for getnamedinsta...

How to prevent 'over-testing' in a test case? (C#/nUnit)

I'm working on some test cases at the moment, and I'm regularly finding that I'm ending up with multiple asserts in each case. For example (over-simplified and comments stripped for brevity): [Test] public void TestNamePropertyCorrectlySetOnInstantiation() { MyClass myInstance = new MyClass("Test name"); Assert.AreEqual("Test Name",...

How can I use unit testing framework on sharepoint 2007?

Hi everyone, I have a MOSS2007 application and now I want to unit test on the application? There is any way to do that? Thanks ...

Rename Unit Test when renaming class Visual Studio

On a related note to this question, which just came up: I commonly follow the naming convention LibraryClass <-> LibraryClassTests for my unit tests. However, when renaming LibraryClass using the default rename/refactor functionality in either Visual Studio, R# or CodeRush (I have tested both) the test file is not renamed, meaning I mig...