unit-testing

Rhino Mocks Partial Mock

I am trying to test the logic from some existing classes. It is not possible to re-factor the classes at present as they are very complex and in production. What I want to do is create a mock object and test a method that internally calls another method that is very hard to mock. So I want to just set a behaviour for the secondary meth...

Why do we need mocking frameworks like Easymock , JMock or Mockito?

Hi, We use hand written stubs in our unit tests and I'm exploring the need for a Mock framework like EasyMock or Mockito in our project. I do not find a compelling reason for switching to Mocking frameworks from hand written stubs. Can anyone please answer why one would opt for mocking frameworks when they are already doing unit tests...

How do you unit test your T-SQL

How do you unit test your T-SQL? Which libraries/tools do you use? What percentage of your code is covered by unit tests and how do you measure it? How do you decide which modules to unit test first? Do you think the time and effort which you invested in your unit testing harness has paid off or not? If you do not use unit testing, ca...

IntentFilter for address book

Hi folks! I have a question regarding the creation of an IntentFilter. I'm currently writing JUnit-tests for an Android application and want to make use of ActivityMonitors. To be more specific: I want to create an ActivityMonitor which listens for calls to the address book as our Application requests the user to choose a contact from ...

When is it appropriate to do interaction based testing as opposed to state based testing?

Hi, When I use Easymock(or a similar mocking framework) to implement my unit tests, I'm forced to do interaction-based testing (as I don't get to assert on the state of my dependencies. Or am I mistaken?). On the other hand if I use a hand written stub (instead of using easymock) I can implement state based testing. I'm quite unclea...

Unit Testing a rails 2.3.5 plugin

I'm writing a new plugin for a rails 2.3.5 app. I've included an app directory (which makes it an engine) so i can easily load some extra routes. Not sure if that affects anything. Anyway, in the test directory i have two files: test_helper.rb and my_plugin_test.rb These files were generated automatically using script/generate plugin...

Any YAML based fixture loader for Java?

I've used DbUnit but after playing about with the Play Framework recently I've found it's Fixtures.load(String yamlFilename) really useful. Anyone know of a similar tool that can be used with any Java project? ...

CPPUnit vs CPPUnit2

Hi, I just noticed that CPPUnit2 exists. Is anyone here using it? Or is CPPUnit the more commonly used of the 2? Thanks. ...

Automate Testing on future only items business rules

I currently have a business object with a validation business rule, which is it can only be created for the future, tomorrow onwards, and I cannot create new items for today. I have a process, which runs the non-future business objects through some steps.. Because I have to set things up today, and test tomorrow, and when it fails, I c...

How to mock the Request.ServerVariables using MOQ for ASP.NET MVC?

hi guys, i'm just learning to put in unit testing for my asp.net mvc when i came to learn about the mock and the different frameworks there is out there now. after checking SO, i found that MOQ seems to be the easiest to pick up. as of now i'm stuck trying to mock the Request.ServerVariables, as after reading this post, i've learned th...

how to unit test AOP?

i'm using Unity to do AOP, could someone give me some idea how to unit test them? ...

Can I use breakpoints (as while debugging) while 'unit testing' ?

Hello, I'm walking through the FrontStore series tutorial on TDD in MVC (Part 3 by Rob Conery/ASP.NET). The test I'm concerned with is the CatalogRepository_Each_Category_Contains_5_Products(). Until I get to that test, everything was working fine. Now, I've gone through every line that makes this test (including the test itself, the Te...

Counterpart for NUnit attribute [SetUp()] in Visual Studio

I am "translating" a NUnit test to Visual Studios unit testing and I am wondering if the attribute [ClassInitialize()] in VS is equivalent to [SetUp()] in NUnit? ...

Is there any good ASP.Net MVC project with TDD & MOQ Source code available?

hi guys, i'm starting to learn TDD, Unit-testing on asp.net mvc and i'm trying to pickup all these mocking via MOQ. so i'm looking for any good asp.net mvc projects which source codes are made available to mere mortals like me :) i've found some good asp.net mvc source codes but not those that uses MOQ specifically. the asp.net mvc s...

Unit Testing - Am I doing it right?

Hi everyone, Basically I have been programing for a little while and after finishing my last project can fully understand how much easier it would have been if I'd have done TDD. I guess I'm still not doing it strictly as I am still writing code then writing a test for it, I don't quite get how the test becomes before the code if you do...

Can Django flush its database(s) between every unit test?

Django (1.2 beta) will reset the database(s) between every test that runs, meaning each test runs on an empty DB. However, the database(s) are not flushed. One of the effects of flushing the database is the auto_increment counters are reset. Consider a test which pulls data out of the database by primary key: class ChangeLogTest(django...

Unit tests and fixtures

We have a bunch of unit tests which test a lot of webpages and REST API services. Currently when our tests run it pulls from these pages live but this can take ages to run sometimes, and it also feels like the tests should be testing more of our code - not just relying on them being up and responding (if that makes sense..). Is it bett...

How to Mock the Internal Method of a class ?

I have a class which has a internal method and i want to mock the internal method . But i am unable to mock it i.e. it is not calling the mocked function but calling the original function. Is there any way to achieve this ? Edit:Actually i am a novice to the Moq. I have many classes and methods of the classes to test using the Moq. Man...

unit-testing maven plugins

Hi, I'm looking for information about how to write unit tests for Maven plugins. Although there's a page on the Maven site about this topic, there's only one example unit test, which does nothing useful. I also found this wiki page, but it hasn't been updated for more than 4 years, so I'm reluctant to invest any faith in it. I checked ...

EJB 3.1 Embedded API - Unit test EJB + JPA entities.

Has anyone done this or attempted to do this for a preexisting project? It seems there are two options to go with here, either using the embedded EJB API basically the following class javax.ejb.embeddable.EJBContainer Which expects a configured glassfish v3 install to be available (application scoped resources will make this easier)...