unit-testing

PHPUnit: Testdependencies with test from parentclass

So, I've got a little problem with my Unittests. I wrote some basisclasses for different Testcases and I want to uses some prepared test-methods. i.e. class ModelTestCase extends PHPUnit_Framework_TestCase { public function testCreateInstance() { ... } } class UserModelTest extends ModelTestCase { /** * (at)depends testCreateIn...

When/How to Unit Test CRUD applications?

I've been hearing alot about unit testing lately. What I'm trying to understand is how would one / should one go about unit testing a cruddy business app? (basically an app that writes data in / reads data out of a database). Is unit testing even worth it in that scenerio or do you usually unit test more complicated things? Thanks ...

android: programatically add id to R.id

i am creating an EditText object which i then try to reference in a unit test. what is the best way to add a new 'id' to R.id for this dynamically created object so that i can later reference it via findViewById() in the unit test? ...

Testing User Controls that utilize a presenter which in turn utilizes wcf services

I have basic WinForm user controls (view) whose intilization includes a presenter and model. The presenter includes calls to a wcf service. Recently an error has croped up that is very trying. Whenever I drag and drop one of these controls onto my design surface I am presented with an error that the endpoint with name "yadda" could ...

JFC unit test tutorial /example

PLease guide me to a nice jfcunit tutorial, plz help me out how to use it, as i could not find more info on that, ...

Grails: test domain object constraints

Hi, I'm trying to test the constraints of my User domain class class UserTests extends GrailsUnitTestCase { protected void setUp() { super.setUp() mockForConstraintsTests(User) } void testEmailConstraint() { // Test e-mail validation def user = new User(userRealName: 'bob', passwd: 'foo') ...

Using Django Cache Middleware causes contrib.auth unit tests to fail

Problem: When I add UpdateCacheMiddleware and FetchFromCacheMiddleware to my Django project, I get unittest failures. This is regardless of the CACHE_BACKEND I use (right now I am using locmem://, but the errors are the same when I use file:///path_to_cache) My Middleware: MIDDLEWARE_CLASSES = ( 'django.middleware.cache.UpdateCache...

Rspec tests hanging with Paperclip

I have a Picture model in my app that uses Paperclip to attach an image to it. The model: class Picture < ActiveRecord::Base has_attached_file :image, :default_url => "/system/:attachment/missing.png", :styles => { :small => "100x100#", :medium => "460x460>", :large => "1024x1024>" } validates_attachment_presence :image validate...

Unit testing puremvc based flex application

Hi, I have a flex application written using PureMVC framework.Now,I want to write tests.We are using FlashBuilder 4.Is FlexUnit sufficient for testing? Are there any issues you have faced while writing tests? ...

Why is PHPUnit in Hudson CI using my localhost path AND my actual filepath?

EDIT 3: Solved. See below. EDIT 2: I think Chadwick's on the right track with his comment. Hudson/PHPUnit is taking the localhost (the Hudson workspace) AND my local file structure and using both to run the unit tests. So it's redeclaring everything that was already declared. Why is this happening and how can I change it? I've since re...

Learning OpenGL while practicing TDD (unit testing)

I have started a new game project, and have decided to learn and use OpenGL for it (project is being simultaneously developed on Windows and Linux). At the same time, I am also very interested in Test Driven Development, and am trying to put my best effort into writing my unit tests to lead design before any actual code. However, I thin...

how do I override php://input when doing unit tests

I'm trying to write a unit test for a controller using Zend and PHPUnit In the code I get data from php://input $req = new Zend_Controller_Request_Http(); $data = $req->getRawBody(); My code works fine when I test the real application, but unless I can supply data as a raw http post, $data will always be blank. The getRawBody() meth...

PHPUnit mock objects and method type hinting

I'm trying to create a mock object of \SplObserver using PHPunit and attach the mocked object to an \SplSubject. When I try to attach the mocked object to a class that implements \SplSubject, I get a catchable fatal error saying that the mocked object doesn't implement \SplObserver: PHP Catchable fatal error: Argument 1 passed to ..\A...

How do i really unit test code?

I was reading the Joel Test 2010 and it reminded me of an issue i had with unit testing. How do i really unit test something? I dont unit test functions? only full classes? What if i have 15 classes that are <20lines. Should i write a 35line unit test for each class bringing 15*20 lines to 15*(20+35) lines (that's from 300 to 825, nearl...

Making Non-Interface Methods Testable in Objective-C

I'm currently writing an Objective-C class which has a relatively complex method in its interface. For the purpose of the question, I'll use the following declaration... @interface Processor : NSObject { } - (NSObject*)doSomeComplicatedProcessing:(NSObject*)param; @end So doSomeComplicatedProcessing is my complicated method. In m...

Is the 'spec' command deprecated in rspec2?

I ask this because typing spec returns this error.. ..ruby-1.9.2-head/lib/ruby/site_ruby/1.9.1/rubygems.rb:335:in `bin_path': can't find executable spec for rspec-2.0.0.beta.17 (Gem::Exception) But 'rspec' seems to work. ...

TDD - What tests should I write for this function?

I've read that I should be writing the simple, basic tests first and gradually moving up to the harder ones. What tests (in order) should I be writing for the following function? function List.syncWithList(lst) should add any items to the list that are not in the list but are in lst should delete any items in the list that are not in ...

Rhino Mocks - Proper usage of Arg<T>.Ref

I'm having problems figuring out the proper arguments of the Arg option in RhinoMocks. I am trying to mock the MSIRecordGetString method which has a ref Int32 parameter. Currently I have: _Api.RecordGetString(Arg<IntPtr>.Is.Anything, Arg<Int32>.Is.Anything, Arg<StringBuilder>.Is.Anything, ...

Troubleshooting: Unable to verify file access to the LocalApplicationData folder when tests run via TeamCity

I have a TeamCity CI Server on a Win7 64 bit machine (running with default settings i.e. service runs in the Local System account) As part of my code, the application creates a log file in the LocalApplicationData folder. _logFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), ...

Testing a image/video conversion class

I have a class that converts images and videos to other formats. A number of options are available such as size, scaling mode, background color, etc (think ImageMagick's convert command). Any ideas for how to test it? The code to exercise all of the options isn't that hard to write, but I'm unsure about how to confirm the results are val...