Skip to content

devasthali-os/scalatest-springboot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

scalatest-springboot

scalatest for springboot. tested against spring-boot 1.x and 2.x

build

mvn clean install

use as deps

    <dependency>
      <groupId>org.scalatest.springboot</groupId>
      <artifactId>scalatest-springboot</artifactId>
      <version>1.0</version>
    </dependency>

TODO add tests

@RunWith(classOf[SpringRunner])
@SpringBootTest
@AutoConfigureMockMvc
class InventoryEndpointIntegrationSpecs extends FunSpec with SpringTestContextManager {

   @Autowired val mockMvc: MockMvc = null

   describe("Inventory Endpoint") {
      it("accepts json request and responds 200 on success"){
        val json = """{}"""
        
        val response =
                mockMvc.perform(MockMvcRequestBuilders.post("/ingest").content(json)).andDo(MockMvcResultHandlers.print())
        
              response.andExpect(MockMvcResultMatchers.status().is(400))
                .andExpect(MockMvcResultMatchers.content().json(
                  """
                    |{
                    |  "eventId": "very-uniq-id",
                    |  "responseCode": "VLDN_FAIL",
                    |  "responseMessage": "[\"object has missing required properties ([\\\"EventBody\\\"])\"]"
                    |}
                  """.stripMargin))
                  
      }
   }
}

TODO

Releases

No releases published

Packages

No packages published

Languages