Logo

dev-resources.site

for different kinds of informations.

Incredibly Useful WireMock with IntelliJ IDEA

Published at
8/13/2024
Categories
mocking
wiremock
intellij
ide
Author
insiderij
Categories
4 categories in total
mocking
open
wiremock
open
intellij
open
ide
open
Author
9 person written this
insiderij
open
Incredibly Useful WireMock with IntelliJ IDEA

Look, WireMock is great! But it can be much better with the proper tooling. And wait no more, seems IntelliJ IDEA 2024.2 now have a proper plugin that finally improves a lot of things around WireMock JSON stubs!

Install WireMock Plugin

It is right here, you need IntelliJ IDEA Ultimate or any other commercial edition of JetBrains IDEs.

From Server Code to Stubs

Let's open a basic Spring PetClinic code and start by creating some stubs for our application. Go to Endpoints tool window, select desired request mappings and open the context menu.

Generating Stubs

Great! Generated stubs posted to the editor:

{
  "mappings": [
    {
      "request": {
        "url": "/owners/find",
        "method": "GET"
      },
      "response": {
        "status": 200
      }
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

As far as I understand, IDE uses special scratch files for that and you can go back to generated code any time:

Scratches

Editing Experience

Once we get to the editor we see completion available and it also validates the correctness of the document.

Code Completion

Run

And what we can do right away without installing anything - start the mock server via run line marker or a floating button in the editor.

Starting Server

Runing

The server is bundled with the plugin so it starts immediately. Let's check if it responds via HTTP Client. It would be a simple request:

Getting 200

Viola! Getting 200 code in return!

Enabling Templates

There is an additional magic button in the editor you can try:

Enabling Templates

It enables Handlebars templating in your stubs files (completion, highlighting, etc). So we can write a more sophisticated stub now:

{
  "request": {
    "urlPathTemplate": "/owners/find/{name}"
  },
  "response": {
    "body": "{{request.path.name}}",
    "transformers": ["response-template"]
  }
}
Enter fullscreen mode Exit fullscreen mode

And IDE helps us with all properties of a request and available functions:

Completion

Conclusion

Not that it is a big deal as AI nowadays, but WireMock plugin for IntelliJ is a huge time-saver for me. Mock everything folks, it pays of!

ide Article's
30 articles in total
Favicon
Remove plugins affecting Intellij idea
Favicon
A Card-Based Approach to Mobile-First IDE
Favicon
PHP: Skip the boring part & press Tab!
Favicon
Amazon Q Developer: The AI-Powered Code Companion Youโ€™ve Been Waiting For
Favicon
Preparando o ambiente de desenvolvimento da melhor API de tabelas de campeonato que vocรช jรก viu!
Favicon
Tools I use in software engineering
Favicon
Plugin Release GitLab Master Plugin - Enhance Your GitLab Experience in IntelliJ IDEA
Favicon
Windsurf was Indeed Better Than Cursor IDE โ€“ t3.gg is biased
Favicon
Mine 14 dage med Cursor
Favicon
Why JetBrains IDEs Are Better Than VS Code for Developers
Favicon
Boosting Developer Efficiency with Cursor IDE: A Comprehensive Tool for Modern Coding
Favicon
Whoever Said You Need An IDE To Program In C?
Favicon
Incredibly Useful WireMock with IntelliJ IDEA
Favicon
How to use AI for coding the right way
Favicon
How To Use Xcode for Windows To Build iOS Apps
Favicon
๐Ÿšจ Google Unveils Project IDX, a Game-Changer for App Development ๐Ÿšจ
Favicon
Use Android Studio Online || React Native Online Mobile View without Android Studio Using Google IDX
Favicon
Migrating a project from Visual studio to Rider
Favicon
Flutter's Essential Toolkit: Top Tools for Every Developer
Favicon
From Text Editors to Cloud-based IDEs - a DevEx journey
Favicon
A Tour of the Couchbase JetBrains Plugin for Developers
Favicon
Project IDX: Google's Cloud-Based Experiment in Streamlining Development
Favicon
Astro vs Visual Studio 2022 as Static Site Generators
Favicon
The Best IDEs for Java Development: A Comparative Analysis
Favicon
Full Line Code Completion by JetBrains: A Game-Changer for Secure, AI-Assisted Coding
Favicon
The project IDX
Favicon
Plugin: Anรกlise de Vulnerabilidade
Favicon
Selecting Your LIGHTWEIGHT Python IDE
Favicon
The Dream Dies: Why Cloud IDEs Failed Developers
Favicon
A IDE do desenvolvedor do futuro ๐Ÿ”ฎ

Featured ones: