[JAVA] JUnit story

JUnit story

A crisp memorandum memo

mockito powerMockito JMockit whitebox

DbSetup is easy to create DB test data in Java DbSetup

Start PowerMock and SpringJUnit4ClassRunner at the same time

@RunWith(PowerMockRunner.class)
@PowerMockRunnerDelegate(SpringJUnit4ClassRunner.class)

Samples for each pattern of mockito and powerMock

https://qiita.com/euledge/items/a224777c15ae7145114a

How to test a private method in Java and partially mock that method

Injection using Spring runner makes it heavier (preferably it can be tested without injection).

InjectionMocks

-You can set a mock in a private field regardless of @Autowired

Injection mock

DBUnit

--Note that if you do not prepare a DB schema for JUnit, the contents of the schema used in development may disappear if you interrupt it.

Private method exams are called by reflection

protected is easier to set with the build path

Session (HTTP)

If you are using a method provided by the library, you may at worst check if the method itself is called. Use fail () (Example :: When checking an abnormal system, you have to make an error when you go to the normal system

Recommended Posts

JUnit story
junit
JUnit 4 notes
Range story
MyBatis story
JUnit memorandum
Java static story
[100%] CyclicRotation (src & jUnit)
[100%] FrogJmp (src & jUnit)
BigDecimal.valueOf (double) story
[100%] FrogRiverOne (src & jUnit)
[100%] OddOccurrencesInArray (src & jUnit)
[100%] MinAvgTwoSlice (src & junit)
[100%] PassingCars (src & junit)
Refactoring in JUnit
[100%] PermCheck (src & junit)
Downcast story (memories)
[100%] TapeEquilibrium (src & jUnit)
[100%] MaxProductOfThree (src & jUnit)
Java initializer story
JUnit5 usage memo
Java generic story
[100%] BinaryGap (src & jUnit)