unit-testing

iPhone - strange error when testing on simulator

Hi I was testing my app on the simulator when it crashed on clicking a button of a UIAlertView. I stopped debugging there, made some changes to the code and built the app again. Now when I run the application, I get this error in the console Couldn't register com.myApp.debug with the bootstrap server. Error: unknown error code. This ge...

Mocking Toolkit using JMockit Expectations

I am trying to mock java.awt.Toolkit.beep() using JMockit Expectations. I have the following code in my test case: new Expectations() { Toolkit mock; { mock.beep(); } }.endRecording(); When I run the test case (JUnit 4), I get the following exception at the "new Expectations" line: java.lang.ClassFormatError: Cod...

How do you stub IQueryable<T>.Where(Func<T, bool>) with Rhino Mocks?

In the .net 3.5 project that I am working on right now, I was writing some tests for a service class. public class ServiceClass : IServiceClass { private readonly IRepository _repository; public ServiceClass(IRepository repository) { _repository = repository; } #region IServiceClass Members pu...

Should I unit test for multithreading problems before writing any lock? (.NET C# TDD)

I am writing a class that I know that needs a lock, because the class must be thread safe. But as I am Test-Driven-Developing I know that I can't write a line of code before creating a test for it. And I find very difficult to do since the tests will get very complex in the end. What do you usually do in those cases? There is any tool to...

Is there a test suite for HTML/JavaScript canvas element?

I'm developing an alternate backend for the canvas interface. I started setting up test cases, and then it occurred to me that there may already by a set of tests, but google isn't forthcoming. ...

PHP and source control: where to put unit tests, etc?

Hi, I'm using Bazaar for version control, which I'm very happy with. In Bazaar every tree/project in source control is called a 'branch'. Currently I have a 'main' branch for the actual application, and a 'dev' branch which houses some things like unit tests, as well as the user manual, etc. This way, both the app and its associated ...

Android Service Testing

How to test my IBinder object that Service return on onBind ? ...

"Hello World" - The TDD way ?

Well I have been thinking about this for a while, ever since I was introduced to TDD. Which would be the best way to build a "Hello World" application ? which would print "Hello World" on the console - using Test Driven Development. What would my Tests look like ? and Around what classes ? Request: No "wikipedia-like" links to what T...

Shoulda, Rails Tests , and Autotest

I'm trying to model my tests after the great work that the Thougtbot guys have done. They seem to use the test framework built into Rails Shoulda. Great. I have been hearing a lot about Autotest - that its magical-ness should make things easier.... I expected that things would 'just work' if I installed it. My rake test:units already a...

How is unit testing better than just testing the entire output of your application as a whole?

Hello, I don't understand how an unit test could possibly benefit. Isn't it sufficient for a tester to test the entire output as a whole rather than doing unit tests? Thanks. ...

What is functional testing?

Hello, What is functional testing? How is this different from unit testing and integral testing? Thanks ...

Is it a good practice to use RowTest in a unit test.

NUnit and MbUnit has a RowTest attribute that allows you to sent different set of parameters into a single test. [RowTest] [Row(5, 10, 15)] [Row(3.5, 2.7, 6.2)] [Row(-5, 6, 1)] public void AddTest(double firstNumber, double secondNumber, double result) { Assert.AreEqual(result, firstNumber + secondNumber); } I used to be huge fan of...

In Spring Webflow unit test, how do you assert that a view state has a view of a given name?

I'm developing a Spring webflow, trying to use TDD so I've extended AbstractXmlFlowExecutionTests. I can't see an obvious way to assert what I would have thought would be a simple thing: that a view state has an associated view of a given name. For example, given this flow (excerpt): <?xml version="1.0" encoding="UTF-8"?> <flow ...> ...

Experiences using moq with VB.Net

I really like the moq mocking framework. I've used it on several projects. Unfortunately, one of my customers is demanding we use VB.Net. Not my preference, but hey, .Net is .Net, right? I've heard that moq has some trouble with VB. Is this true? Is so, what sorts of trouble? I would expect it to work fine given the language agnos...

Rails: How to test code in the lib/ directory?

I have a model which gets its data from a parser object. I'm thinking that the parser class should live in the lib/ directory (although I could be persuaded that it should live soewhere else). The question is: Where should my unit tests for the parser class be? And how do I ensure that they are run each time I run rake test? ...

Unit testing XNA: Do I need to Mock my GraphicsDevice

I'm fooling around with the XNA framework. To help me around I made a helper class that looks like this: ActorHolder + SpriteBatch (SpriteBatch) + ContentManager (ContentManager) - drawables (IList<IDrawable>) - updatables (IList<IUpdatable>) + ActorHolder(GraphicsDevice, ContentManager) + Draw(GameTime) + Update(GameTime) + AddActor(I...

Unit testing in PHP?

I've been thinking about writing unit tests for my PHP/MySQL projects. The thing that bugs me is how i can test things like form validation, ajax features, and UI features (such as clicking links). Also, I don't want the tests to be dependent on one aspect of the UI, so if I moved one link then all tests would break. Does anyone have a...

NUnit: Parametric test with generic methods

In NUnit 2.5 you can do this: [TestCase(1,5,7)] public void TestRowTest(int i, int j, int k) { Assert.AreEqual(13, i+j+k); } You can do Parametric test. But I wonder whether you can do this or not, Parametric test with generic test method?, i.e., [TestCase <int>("Message")] public void TestRowTestGeneric<T>(string msg) { Assert....

How to unit test full text search in ASP.NET MVC

I've just started out using ASP.NET MVC and TDD. I've read that while unit testing you should focus on testing your code, not other systems, like the DB. However, what happens when essential functionality is residing in the DB? I've used the MVC Storefront series as an initial guide in how to set up my projects and patterns. As full tex...

Unit testing with generated DAL code

I use a code generator (CodeSmith with .NetTiers template) to generate all the DAL code. I write unit tests for my code (business layer), and these tests are becoming pretty slow to run. The problem is that for each test, I reset the database to have a clean state. Also, as I do a lot of tests, it seems that the latency of the database o...