I have a method I want to test but it's marked with @PostConstruct annotation. This method at some point, throw an exception. Is it possible to test a method with such annotation using JUnit tests? Asking in general here rather than for a specific method
Asked
Active
Viewed 191 times
0
Nathaniel Cutajar
- 302
- 3
- 14
-
1Yes - it's the same as any other method. – Andrew S Apr 15 '21 at 14:43
1 Answers
0
Yes, you can test it as usual method, because @PostConstruct is Spring-specific annotation and isn't related to JUnit (this annotation will be proceed only if you use features from spring-test library like SpringRunner, @SpringBootTest and so on).
amseager
- 5,795
- 4
- 24
- 47