This link has been bookmarked by 37 people . It was first bookmarked on 30 Jun 2008, by N T.
-
11 May 15
-
23 Jul 13
-
07 Mar 13
-
19 Nov 12
-
How do I handle dependencies?
-
In order for it to be a unit test, it must test something in isolation, aka without dependencies.
-
The reason for this is that we are testing the component itself and not it's interaction with other components (that is an integration test).
-
"...in a repeatable way" is a very important piece of the definition
-
Select JUnit 4 and click Finish.
-
add the EasyMock
-
In test driven design, we develop the unit test before the functionality
-
in this tutorial UserDAO will be mocked,
-
The lifecycle of a test execution consists of three main methods
-
mockDao
-
We will use it to instantiate our required * objects so that we get a clean copy for each test.
-
EasyMock works by implementing the proxy pattern
-
The proxy object gets it's definition from the interface you pass when creating the mock
-
It tells your mock object to expect the method loadByUsernameAndPassword to be called.
-
so we have to use one of EasyMock's comparators instead
-
This tells our mock object what to return after this method is called
-
replay(mockDao);tells EasyMock "We're done declaring our expectations. It's now time to run what we told you" -
assertTrue(service.login(userName, password));does two things: executes the code to be tested and tests that the result is true. -
verify(mockDao);tells EasyMock to validate that all of the expected method calls were executed and in the correct order.
-
-
04 Mar 12
-
07 Feb 12
-
Unit testing with JUnit and EasyMock
-
-
24 Jan 12
-
30 Aug 11
-
22 Aug 11
-
31 May 11
-
06 Apr 11
-
16 Aug 10
-
21 Apr 10
-
24 Mar 10
-
04 Jan 10
-
11 Dec 09
-
27 Nov 09
-
01 Jun 09
-
28 Apr 09
-
16 Mar 09
-
26 Sep 08
-
11 Sep 08
-
This is what separates a unit test from other types of tests. In order for it to be a unit test, it must test something in isolation, aka without dependencies. The reason for this is that we are testing the component itself and not it's interaction with other components (that is an integration test).
-
In test driven design, we develop the unit test before the functionality.
-
We will start our coding by defining two interfaces, LoginService and UserDAO We will implement LoginService, however since in this tutorial UserDAO will be mocked, we won't bother implementing it right now.
-
Before we begin development, we will develop our test. Tests are structured by grouping methods that perform a test together in a test case. A test case is a class that extends junit.framework.TestCase. So in this case, we will begin by developing the test case for LoginService.
-
When you create a mock object, it creates a proxy object that takes the place of the real object. The proxy object gets it's definition from the interface you pass when creating the mock.
-
-
04 Aug 08
-
03 Aug 08
-
30 Jun 08
-
26 Jun 08
lencielSession 2
-
25 Jun 08
Geir AmdalWe all have it. It's that piece of code in our project that everyone is afraid to change. It's so confusing no one truly understands what is going on. We are all afraid that if we do change it, we'll break it. You have just discovered my favorite reason f
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.