I've been trying to jump on the TDD bandwagon for some time now, and it's been going well except for one crucial thing, normally what I end up doing is Test After Development.
I need a mental shift and am wondering how did you force yourself to write tests first?
...
I'd like to brush my brain to avoid confusions. In few words, what can be said about Mocking process in TDD
What's the GREAT idea behind MOCKING?
Mocking frameworks are meant to be used only to avoid accessing DB during tests or they can be used for something else?
For new comers (like me), are all the frameworks equal or I need to ch...
Hi!
Assume we have a class UserService with attribute current_user. Suppose it is used in AppService class.
We have AppService covered with tests. In test setup we stub out current_user with some mock value:
UserService.current_user = 'TestUser'
Assume we decide to rename current_user to active_user. We rename it in UserService but ...
I'm considering remaking my blog(currently in PHP, but <100 lines of non-layout code) in Ruby on Rails just for the fun of it. I want to make another project in Rails, but I should learn Rails(more than hello world) before I go to try to create a full project.
Another thing I want to do while remaking my blog is to at least figure out ...
I have a few repository classes that are meant to talk to different kinds of data, deriving from an IRepository interface laid out like so:
In implementations, the code talks to a data source, be this a directory of XML files or a database or even just a cache. Is it possible to reliably unit test any of these implementations? I don't...
hi there,
i'm trying to learn how to properly setup testing for an ASP.Net MVC.
and from what i've been reading here and there thus far, the definition of legacy code kind of piques my interests, where it mentions that legacy codes are any codes without unit tests.
so i did my project in a hurry not having the time to properly setup un...
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...
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...
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...
Is there a "best practice" or defacto standard with how much of the GORM functionality one should test in the unit/functional tests?
My take is that one should probably do most of the domain testing as functional tests so that you get the full grails environment. But what do you test? Inserts, updates, deletes? Do you test constraints e...
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...
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...
I have a method in a class for which they are a few different outcomes (based upon event responses etc). But this is a single atomic function which is to used by other applications.
I have broken down the main blocks of the functionality that comprise this function into different functions and successfully taken a Test Driven Developme...
Using NUnit and Moq, I am trying to wrap some tests around legacy code before I do too much more refactoring. I need to test that a method keeps looping until told to stop. Here is my idea how to do it:
[TestCase]
public void KeepsCallingDoSomethingUntilShouldIKeepGoingIsFalse()
{
var dal = new Mock<IDataAccessLayer>();
var sut = ...
Hi guys,
I'm newbie to Java EE 6 and i'm trying to develop very simple JAX-RS application. RESTfull web service working fine. However when I ran my test application, I got the following. What have I done wrong? Or am i forget any configuration? Of course i'm create a JNDI and i'm using Netbeans 6.8 IDE. In finally, thank you for any adv...
I've performed the "Replace Method with Method Object" refactoring described by Beck.
Now, I have a class with a "run()" method and a bunch of member functions that decompose the computation into smaller units. How do I test those member functions?
My first idea is that my unit tests be basically copies of the "run()" method (with diff...
I have a function to test, under_test, and a set of expected input/output pairs:
[
(2, 332),
(234, 99213),
(9, 3),
# ...
]
I would like each one of these input/output pairs to be tested in its own test_* method. Is that possible?
This is sort of what I want, but forcing every single input/output pair into a single test:
class TestPr...
In Osherove's great book "The Art of Unit Testing" one of the test anti-patterns is over-specification which is basically the same as testing the internal state of the object instead of some expected output. To my experience, using Isolation frameworks can cause the same unwanted side effects as testing internal behavior because one tend...
Today I am going to get as far as I can setting up my testing environment and workflow. I'm looking for practical advice on how to setup the test environment from you guys who are very passionate and versed in Ruby Testing.
By the end of the day (6am PST?) I would like to be able to:
Type one 1-command to run test suites for ANY proj...
Hello all,
I'm seleting tool for populating my .net models (poco) with test data. I'm actually mocking wcf services and need to populate datacontract objects with test data. Found a huge number of test data generation tools, but the majority is realted to DB test data generation and don't fit well for .net objects creatiom.
The most a...