unit-testing

How do I mock a method with an open array parameter in PascalMock?

I'm currently in the process of getting started with unit testing and mocking for good and I stumbled over the following method that I can't seem to fabricate a working mock implementation for: function GetInstance(const AIID: TGUID; out AInstance; const AArgs: array of const; ...

WP7-Silverlight Asynchronous Unit Test, EnqueueCallBack is not supported by the language?

I am working on a unit test for a Windows Phone 7 Silverlight app. The code for the test looks like this: [TestMethod] [Asynchronous] public void StuffIsLoading() { WaitFor(_repository, "LoadingStuffComplete"); var viewModel = new MainPageViewModel(_repository); EnqueueCallback(() => Assert.IsTrue(viewModel.Stuf...

Testing with Unittest Python

Hello, I am runninig test's with Python Unittest. I am running tests but I want to do negative testing and I would like to test if a function throw's an exception, it passes but if no exception is thrown the test fail's. The script I have is: try: result = self.client.service.GetStreamUri(self.stream, self.token) se...

Emma - Block Coverage vs Line Coverage

I have a strange scenario... while doing a EMMA coverage for UT, I get the total block coverage size more than line coverage size. For block coverage, the total size is some 50,000 while the line coverage is out of 18,000. I get (block-coverage-value) / 50,000 and (line-coverage-value) / 18,000 in the report. Is it possible? How can t...

What is the preferred unit testing framework for Perl?

I'm sort of new to Perl and I'm wondering if there a prefered unit testing framework? Google is showing me some nice results, but since I'm new to this, I don't know if there is a clear preference within the community. ...

How to write unit test before the class code?

I am trying to get into the habit of writing a unit test before the actual class. What are some pointers the stack overflow community can give me along with any useful resources. Thank You ...

Looking for a good material to adopt unit-test coding approach

Hi, this is something I know I should embrass in my coding projects but, due to lack of knowledge and my legendary lazyness, I do not do. In fact, when I do them, I feel like overloaded and I finally give up. What I am looking for is a good book/tutorial on how to really write good tests -i.e useful and covering a large spectrum of th...

Unit Testing: hard dependency MessageBox.Show()

What ways can the SampleConfirmationDialog be unit tested? The SampleConfirmationDialog would be exercised via acceptance tests, however how could we unit test it, seeing as MessageBox is not abstract and no matching interface? public interface IConfirmationDialog { /// <summary> /// Confirms the dialog with the user /// </s...

Unit Testing & Fake Repository implementation with cascading CRUD operations

Hi, i'm having trouble writing integration tests which use a fake repository, For example : Suppose I have a classroom entity, which aggregates students... var classroom = new Classroom(); classroom.Students.Add(new Student("Adam")); _fakeRepository.Save(classroom); _fakeRepostiory.GetAll<Student>().Where((student) => student.Name ==...

Why is django.test.client.Client not keeping me logged in.

I'm using django.test.client.Client to test whether some text shows up when a user is logged in. However, I the Client object doesn't seem to be keeping me logged in. This test passes if done manually with Firefox but not when done with the Client object. class Test(TestCase): def test_view(self): user.set_password(passwor...

Multiple Asserts in a Unit Test

I've just finished reading Roy Osherove's "The Art of Unit Testing" and I am trying to adhere to the best practices he lays out in the book. One of those best practices is to not use multiple asserts in a test method. The reason for this rule is fairly clear to me, but it makes me wonder... If I have a method like: public Foo MakeFoo(i...

Unit-test framework for bean comparison

Is there any good framework for comparing whole objects? now i do assertEquals("[email protected]", obj.email); assertEquals("5", obj.shop); if bad email is returned i never get to know if it had the right shop, i would like to get a list of incorrect fields. ...

JUnit - assertSame

Can someone tell me why assertSame() do fail when I use values > 127? import static org.junit.Assert.*; ... @Test public void StationTest1() { .. assertSame(4, 4); // OK assertSame(10, 10); // OK assertSame(100, 100); // OK assertSame(...

how often should the entire suite of a system's unit tests be run?

Generally, I'm still very much a unit testing neophyte. BTW, you may also see this question on other forums like xUnit.net, et cetera, because it's an important question to me. I apoligize in advance for my cross posting; your opinions are very important to me and not everyone in this forum belongs to the other forums too. I was ...

How to refactor my class so I can unit test it?

I am trying to unit test a class that does SAX parsing and creates an object. This class takes a string as a parameter representing the URL of a document on the internet, parses it and then creates an object based on the contents. I don't want to have the unit tests actually access the network, so I'd like to have a few test xml files t...

Throwing special type of exception to terminate unit test

Assume I want to write a unit test to test a particular piece of functionality that is implemented within a method. If I wanted to execute the method completely, I would have to do some extra set up work (mock objects expectations etc.). Instead of doing that I use the following approach: - I set up the expectations I'm interested in ver...

Why does false invalidate validates_presence_of?

Ok steps to reproduce this: prompt> rails test_app prompt> cd test_app prompt> script/generate model event_service published:boolean then go into the migration and add not null and default published to false: class CreateEventServices < ActiveRecord::Migration def self.up create_table :event_services do |t| t.boolean :pub...

Any suggestions for improvement on this style for BDD/TDD?

I was tinkering with doing the setups with our unit test specifciations which go like Specification for SUT when behaviour X happens in scenario Y Given that this thing And also this other thing When I do X... Then It should do ... And It should also do ... I wrapped each of the steps of the GivenThat in Actions... any f...

JUnit - Testing a method that in turn invokes a few more methods

Hi, This is my doubt on what we regard as a "unit" while unit-testing. say I have a method like this, public String myBigMethod() { String resultOne = moduleOneObject.someOperation(); String resultTwo = moduleTwoObject.someOtherOperation(resultOne); return resultTwo; } ( I have unit-tests wri...

First TDD, Simple 2-tier C# Project - what do I unit test?

This is probably a stupid question but my googling isn't finding a satisfactory answer. I'm starting a small project in C#, with just a business layer and a data access layer - strangely, the UI will come later, and I have very little (read:no) concept / control over what it will look like. I would like to try TDD for this project. I'...