unit-testing

Entire monorail action invocation in tests

BaseControllerTest.PrepareController is enough for controller properties setup, such as PropertyBag and Context [TestClass] public ProjectsControllerTest : BaseControllerTest { [TestMethod] public void List() { // Setup var controller = new ProjectsController(); PrepareController(controller); controller.List(); // Asserts ...

How do I turn off shadow copy in a Visual Studio 2010 test project?

When using NUnit, I can turn off shadow copy so that my test assemblies are run from the output directory. I need this because my tests in this case aren't unit tests, but are integration tests which need to be able to access some of the assemblies that are copied into the output directory by the build. However, I can't find a way of t...

how can i get controller B's action in rails specs for controller A?

how can i get controller B's action in rails specs for controller A? ...

Mock static property with moq

I am pretty new to use moq. I am into creating some unit test case to HttpModule and everything works fine until I hit a static property as follows this.applicationPath = (HttpRuntime.AppDomainAppVirtualPath.Length > 1) ? HttpRuntime.AppDomainAppVirtualPath : String.Empty; I do not know how create mocks for static class and...

What to test when writing Unit Tests?

I want to begin unit testing our application, because I believe that this is the first step to developing a good relationship with testing and will allow me to branch into other forms of testing, most interesting BDD with Cucumber. We currently generate all of our Base classes using Codesmith which are based entirely on the tables in a...

Is unit testing viable in game programming?

I'm fond of the idea of unit testing but I'm having trouble applying it to game programming. Games are highly stateful and often the code doesn't break itself into distinct units. In my experience, most functions mutate state rather than returning values. Consider a simple action like playerJump(height). I'd love to have a test suite th...

Unit test framework - TestNG using configurable value to define threadPoolSize

Hi guys.... I'm digging little bit the TestNG framework. I'm using annotations to configure thread values in my test case, example: @Test(threadPoolSize = 2, invocationCount = 10) public void testOne() { //some code } The idea is config these values in a config file and this values should be passed to all tests. So I...

How to mock a before filter variable assignment? ActionController::TestCase

The idea is as follows: when visiting a purchase page, the pre-initialized (using before_filter) @purchase variable receives save if the item in question is not free. I make two gets, one for a paid item and one for a free item. purchase.expects(:save).returns(true) expects :save to be called only once, so the below test works. But th...

iphone error when unit testing: Expected '=', ',', ';', 'asm' or '__attribute__' before '*' token

I get the following error when I try to build (Build->build) a unit test. My unit test is a logic test (it does not run on the device). Things that are probably related to my problem are: I am using libxml2 and a wrapper around it (which i found at cocoawithlove). This wrapper has some C functions defined (it is not an Objective C cla...

Would you consider this a proper test case?

I would like to get some feedback on what is one of my first PHPUnit test cases. The subject of the tests is a simple configuration class in a PHP app. It is used to create, store and retrieve configuration settings. The settings are stored in an array within the class. Each setting has the following properties: key (for example fro...

Why is PHPUnit ignoring assertions when expecting an exception?

I have a simple unit test case (extensive question here) on a configuration class that by design triggers PHP errors on type mismatches and undefined configuration settings. In addition to the error, the method is exited returning false. In my test case, I want to have a number of tests that fail. Trouble is, I can't do a simple 'assert...

Unit Testing Refcounted Critical Section Class

Hello all :) I'm looking at a simple class I have to manage critical sections and locks, and I'd like to cover this with test cases. Does this make sense, and how would one go about doing it? It's difficult because the only way to verify the class works is to setup very complicated threading scenarios, and even then there's not a good w...

"Web interface" to PHPUnit tests?

Is there a simple "Web interface" to running PHPUnit test suites? i.e. a PHP script that runs the test on the command line, and outputs a nicely formatted HTML result. I develop web applications, and the day-to-day workflow usually switches between the IDE and the browser. I would like to have the unit testing in the same environment. ...

Preconfigure Android Emulator with location?

I want to run automated tests with location on the android emulator. I can setup coordinates via Telnet, but that means starting up a console and manually configuring the emulator before running my junit tests. Is there a possibility to preconfigure the emulator with a KML file or something like that to ensure that there are always co...

a problem with NUnit environment

I have a problem: if i run this test in NUnit ,it works Board board = new Board("ab", 12, 120,BoardType.OEM, BoardSide.DoubleSide); Assert.NotNull(board); but when i want to add another Assert statement as Assert.AreEqual(board.SNR, "ab"); it runs, and the NUnit window is immediately closed. Why does it close automaticaly? ...

Unit Testing: DateTime.Now

I have some unit tests that expects the 'current time' to be different than DateTime.Now and I don't want to change the computer's time, obviously. What's the best strategy to achieve this? Thanks ...

Rhino Mocks DynamicMultiMock - setting expectation with return value on additional interface

Hello, I am creating a DynamicMultiMock as follows: this.serviceClient = this.mocks.DynamicMultiMock<ISlippyPlateProcedureService>(typeof(ICommunicationObject)); Then setting the following expectation: Expect.Call(((ICommunicationObject)this.serviceClient).State).Return(CommunicationState.Faulted); When I execute the test, Rhino M...

Moq + VB.NET - will it be fully supported in VS2010 automatically in its current form?

Hello, We are looking to make a final decision on our Mocking framework. After trying several, I have fallen in love with Moq. I also love TypeMock - but because we are in the early stages of implementing TDD across the team, we do not want to make such a large investment quite yet. We are using VS 2008 now and are going to move to 2010...

Legacy Database, Fluent NHibernate, and Testing my mappings

As the post title implies, I have a legacy database (not sure if that matters), I'm using Fluent NHibernate and I'm attempting to test my mappings using the Fluent NHibernate PersistenceSpecification class. My question is really a process one, I want to test these when I build locally in Visual Studio using the built in Unit Testing f...

Convert C# unit test names to English (testdox style)

I have a whole bunch of unit tests written in MbUnit and I would like to generate plain English sentences from test names. The concept is introduced here: http://dannorth.net/introducing-bdd This is from the article: public class CustomerLookupTest extends TestCase { testFindsCustomerById() { ... } testFailsForDupl...