Skip to content
Advertisement

Tag: junit

Why does cucumber run @Before in all glue code files

I have a problem with my cucumber tests. It runs the @Before method in all the glue classes. For example. This feature file have one glue code in the MainStepDef.class. The MainStepDef: I have an additional glue file called: OtherStep.class And finally I have my runner class. When I run this I get the runtime exception from the OtherStepDef setup

Testing image files with JUnit

I’m looking for direction on how to test that a dynamically generated image is the expected image with JUnit. A bit of background: I have code that generates thumbnail images as java.awt.image.BufferedImage’s and stores those BufferedImages into a java.io.File object. I wrote a simple unit test to check a few key items in order to gain confidence that the generated

How to write a unit test for a Spring Boot Controller endpoint

I have a sample Spring Boot app with the following Boot main class Controller What’s the easiest way to write a unit test for the controller? I tried the following but it complains about failing to autowire WebApplicationContext Answer Spring MVC offers a standaloneSetup that supports testing relatively simple controllers, without the need of context. Build a MockMvc by registering

How to get the path of src/test/resources directory in JUnit?

I know I can load a file from src/test/resources with: But how can I get the full path to the src/test/resources directory, i.e. I don’t want to load a file, I just want to know the path of the directory? Answer Try working with the ClassLoader class: A ClassLoader is responsible for loading in classes. Every class has a reference

Spring junit tests with couchbase

I have some Services that should get documents from couchbase. Services: Also I have DocRepository interface with necessary methods and views on couchbase server. When I run my app and call Services its work fine, but I need tests for this Services. Tests: Running tests successful only in 90%. And another moment, I use maven, and when it runs tests

Advertisement