Spring Boot GraphQL Tutorial #27 - Integration Testing (GraphQLTestTemplate)

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ต.ค. 2024

ความคิดเห็น • 25

  • @chillappreciator885
    @chillappreciator885 ปีที่แล้ว

    This one episode is super helpful, thanks

  • @keweiwang1449
    @keweiwang1449 3 ปีที่แล้ว

    Hi Philip, Thank you for your great video, so currently our company doing the integration test with cucumber framework and when we are running the it, we will spin up serval docker containers (such as DB, MQ and so on) with docker compose, and just like what you did in the video (but run the it in command line, the application will connect to DB in docker container), but we create new folders for each individual query and mutation

  • @samirsavasani1
    @samirsavasani1 ปีที่แล้ว

    I am getting 404 when using GraphQLTestTemplate. "error":"Not Found","path":"/graphql"

  • @Miifor
    @Miifor 3 ปีที่แล้ว

    In the video you did the GraphQL query with a premade graphql file and asserted the expected response with premade JSON. I would imagine as the GraphQL API grows, the amount of these two files would keep on growing making it a huge pain to maintain which JSON response will come from which graphql file. With REST I've used RestAssured, which can be used to create the requests with a builder class like get("/bankaccount/123").then().extract().response() for sending the requests. GraphQL queries can have a lot more going for them than my REST example but do you know if there is a way to write graphQL queries in a similar Java fashion? Premade JSON responses on the other hand can be eliminated by deserializing the response into a POJO with Jackson.
    All in all I'm liking your videos. I'm doing a GraphQL project myself and have been following the steps you've taken.

    • @PhilipStarritt
      @PhilipStarritt  3 ปีที่แล้ว

      For the correlation of the files to the test, I name the graphql files with the test methods name. That seems to help us. If you dont want to maintain full Jsons you can also choose from a range of fluent DSL methods such as Json expression assert inside the GraphQLResponse class. I don’t think you need full jsons for all tests , but certainly for core application use-cases (flows) or public APIs then they are beneficial. We have found over the years, they take a bit more time to maintain but are worth it . One of the the purposes of the Jsons is to actually avoid the deserialisation process in the test. This can catch non backwards compatible changes, for example renaming a field. If you change the variable name- the test may still pass if you use the same domain object. Maybe there are nicer ways though? Also - Maybe you have already tried - but deserializing into the relay connection classes can be painful - but I hope this helps and have fun learning 🙂 enjoy your weekend

    • @Miifor
      @Miifor 3 ปีที่แล้ว

      @@PhilipStarritt Haven't yet used connection relays but they can complicate the deserialization. I'll see when I get there! Validating backwards compatibility is a good point for the tests although I still dislike having cumbersome JSONs in the tests. I don't see any other way to do it than maybe reflection which isn't too pretty either.
      Thank you for your comment and have a pleasant weekend as well!

    • @PhilipStarritt
      @PhilipStarritt  3 ปีที่แล้ว

      @@Miifor no problem! If you do manage to find an alternative without reflection then please come back - or even better , share a video with us 🙂

  • @nikitanawani3782
    @nikitanawani3782 3 ปีที่แล้ว

    Hi Philip, really an informational video. In my company the graphql query is interacting with hbase server and in dev we dont have hbase connection. how to write a test case for that?? Can you help with any solution for that?

    • @PhilipStarritt
      @PhilipStarritt  3 ปีที่แล้ว

      Good morning Nikita , one idea is to start an Hbase server with testcontainers before you execute the integration test. When the integration test starts , it should create any required schema creation/ database objects. Then you can execute your test . Consider inserting mock data before the individual tests run. Just one idea out of many possibilities - good luck with your research

    • @chenandy2843
      @chenandy2843 3 ปีที่แล้ว

      if you using Spring Data Jpa Or Something, you can use @MockBean on Repository, and then use BDDMockito.when(repository.findAll()).then(here_it_test_object_your_want_to_return); finally you will get the entity list that you set,just like those response from database

  • @chillappreciator885
    @chillappreciator885 ปีที่แล้ว

    One day your Enter key will leave the chat)

  • @divyasharma9616
    @divyasharma9616 2 ปีที่แล้ว

    I am getting error 404 when using @GraphQLTest during integration testing. Can someone please help here

  • @ayyasamys1011
    @ayyasamys1011 4 ปีที่แล้ว +1

    Hi your videos are good. But please zoom and write the code bcoz it's not visible.

    • @PhilipStarritt
      @PhilipStarritt  4 ปีที่แล้ว +2

      Ok I will try to improve on that thanks 👍🏼

    • @PhilipStarritt
      @PhilipStarritt  3 ปีที่แล้ว +1

      I zoomed in my latest video (30) - how was it ?

    • @ayyasamys1011
      @ayyasamys1011 3 ปีที่แล้ว +1

      @@PhilipStarritt its very clear now. Thanks

  • @sudhanshugera134
    @sudhanshugera134 3 ปีที่แล้ว

    I have a dB where the data goes. How to make in memory dB and perform gql operations there?

    • @PhilipStarritt
      @PhilipStarritt  3 ปีที่แล้ว

      Try H2

    • @sudhanshugera134
      @sudhanshugera134 3 ปีที่แล้ว

      @@PhilipStarritt yeah. Tried that I am getting 404 when I do postForResourcre.

  • @HighOnCaffein3
    @HighOnCaffein3 ปีที่แล้ว +1

    Nice tutorial. But the audio should be a voice over, too much keyboard and mouse noises.

    • @fguille94
      @fguille94 11 หลายเดือนก่อน

      I was just thinking on nice it was that I could heard keyboard and mouse noises, makes it more real