Skip to content

Commit 2b5eb41

Browse files
Updating README file
1 parent 3bc0e36 commit 2b5eb41

File tree

1 file changed

+122
-1
lines changed

1 file changed

+122
-1
lines changed

README.md

Lines changed: 122 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,122 @@
1-
# unit-testing-and-integration-testing-with-spring-boot
1+
# Unit Testing and Mockito Tutorial
2+
In this tutorial, we will understand how to write JUnit test cases. We will understand and implement the below topics.
3+
4+
[**JUnit Tutorial**](https://onlyfullstack.blogspot.com/2019/02/junit-tutorial.html)
5+
6+
**Part 1 - What is Unit Testing?**
7+
In this tutorial, we will understand below topics -
8+
- What is Unit Testing?
9+
- Unit Testing Method
10+
- When is it performed?
11+
- Who performs it?
12+
- How to perform it?
13+
[**https://onlyfullstack.blogspot.com/2019/02/what-is-unit-testing.html**](https://onlyfullstack.blogspot.com/2019/02/what-is-unit-testing.html)
14+
15+
**Part 2 - ** What is JUnit? How to use JUnit?**
16+
In this tutorial, we will understand below topics -
17+
- What is Junit?
18+
- How to use Junit?
19+
- Where should the test be located?
20+
- How to execute JUnit tests?
21+
1. Using mvn command
22+
2. Using Eclipse Run as \> JUnit Test
23+
- Eclipse Optimize Imports to Include Static Imports
24+
[**https://onlyfullstack.blogspot.com/2019/02/what-is-junit-how-to-use-junit.html**](https://onlyfullstack.blogspot.com/2019/02/what-is-junit-how-to-use-junit.html)
25+
26+
**Part 3 - Annotations used in JUnit**
27+
In this tutorial, we will understand below topics -
28+
- How to define a test in JUnit?
29+
- Annotations used in Junit
30+
1. @Test
31+
2. @Before
32+
3. @After
33+
4. @BeforeClass
34+
5. @AfterClass
35+
6. @Ignore or @Ignore("Why disabled")
36+
7. @Test (expected = Exception.class)
37+
[**https://onlyfullstack.blogspot.com/2019/02/annotations-used-in-junit.html**](https://onlyfullstack.blogspot.com/2019/02/annotations-used-in-junit.html)
38+
39+
**Part 4 - JUnit Assert Methods**
40+
In this tutorial, we will understand below topics -
41+
- Assert Methods
42+
1. assertEquals()
43+
2. assertTrue() + assertFalse()
44+
3. assertNull() + assertNotNull()
45+
4. assertSame() and assertNotSame()
46+
5. assertThat()
47+
[**https://onlyfullstack.blogspot.com/2019/02/junit-assert-methods.html**](https://onlyfullstack.blogspot.com/2019/02/junit-assert-methods.html)
48+
49+
**Part 5 - Complete guide for Hamcrest JUnit**
50+
In this tutorial we will understand below topics-
51+
- Hamcrest Matcher Tutorial
52+
- The Core Matchers
53+
1. CoreMatchers.is(T value)
54+
2. CoreMatchers.not(T value)
55+
3. CoreMatchers.startsWith(String prefix) & CoreMatchers. endsWith(String suffix)
56+
4. CoreMatchers.containsString(String substring)
57+
5. CoreMatchers.notNullValue()
58+
6. CoreMatchers.sameInstance(T target) & CoreMatchers.instanceOf(Class\<?\> type)
59+
- Number Matcher
60+
1. Matchers.greaterThan(T value) Matchers.greaterThanOrEqualTo(T value)
61+
2. Matchers.lessThan(T value) Matchers.lessThanOrEqualTo(T value)
62+
- Collection Matcher
63+
1. Matchers.empty()
64+
2. Matchers.hasSize(int size) and Matchers.hasItem(T item)
65+
3. Matchers. hasKey(K key), Matchers.hasValue(V value) & Matchers.hasEntry(K key, V value)
66+
67+
[**https://onlyfullstack.blogspot.com/2019/02/complete-guide-for-hamcrest-junit.html**](https://onlyfullstack.blogspot.com/2019/02/complete-guide-for-hamcrest-junit.html)
68+
69+
**Part 6 - Assert for an exception in JUnit**
70+
In this tutorial, we will understand below topics-
71+
- How do you assert that a certain exception is thrown in JUnit 4 tests?
72+
1. try-catch idiom
73+
2. @Test expected annotation
74+
3. Junit @Rule
75+
[**https://onlyfullstack.blogspot.com/2019/02/assert-for-exception-in-junit.html**](https://onlyfullstack.blogspot.com/2019/02/assert-for-exception-in-junit.html)
76+
77+
78+
**_____________________________________________________________________________________________**
79+
80+
**Mockito Tutorial**
81+
82+
[**Mickito Tutorial**](https://onlyfullstack.blogspot.com/2019/02/mockito-tutorial.html)
83+
84+
In this tutorial, we will understand how to use Mockito framework. We will understand and implement the below topics.
85+
86+
**Part 1 - What is Mockito?**
87+
In this tutorial, we will understand below topics -
88+
- What is a Mock Object?
89+
- When should I mock?
90+
- Mockito Framework
91+
- Enable Mockito Annotations
92+
- How to Mock Object with @Mock & @InjectMock annotations in Spring application?
93+
[**https://onlyfullstack.blogspot.com/2019/02/what-is-mockito.html**](https://onlyfullstack.blogspot.com/2019/02/what-is-mockito.html)
94+
95+
**Part 2 - How to mock methods with Mockito?**
96+
- How to mock methods?
97+
1. when/then
98+
2. when/thenThrow
99+
3. when/thenAnswer
100+
[**https://onlyfullstack.blogspot.com/2019/02/how-to-mock-methods-with-mockito.html**](https://onlyfullstack.blogspot.com/2019/02/how-to-mock-methods-with-mockito.html)
101+
102+
**Part 3- How to mock void methods with Mockito**
103+
- Mocking Void Methods
104+
- Three ways to mock the void method:
105+
1. doNothing/when
106+
2. doAnswer/when
107+
3. doThrow/when
108+
[**https://onlyfullstack.blogspot.com/2019/02/how-to-mock-void-methods-with-mockito.html**](https://onlyfullstack.blogspot.com/2019/02/how-to-mock-void-methods-with-mockito.html)
109+
110+
**Part 4 - How to verify mocks in Mockito**
111+
- Simple verify method
112+
- Variations in verify method
113+
- Verify with the number of times
114+
- Mockito Verify Order of Invocation
115+
[**https://onlyfullstack.blogspot.com/2019/02/how-to-verify-mocks-in-mockito.html**](https://onlyfullstack.blogspot.com/2019/02/how-to-verify-mocks-in-mockito.html)
116+
117+
**Part 5 - **** Mockito Mock vs Spy**
118+
- Mockito Mock vs Spy
119+
1. Object declaration
120+
2. When the methods are not mocked
121+
3. When the method is mocked
122+
[**https://onlyfullstack.blogspot.com/2019/02/mockito-mock-vs-spy.html**](https://onlyfullstack.blogspot.com/2019/02/mockito-mock-vs-spy.html)

0 commit comments

Comments
 (0)