Java on Visual Studio Code Update – January 2021
Welcome to the first edition of VS Code update for Java in 2021. We got some questions around how to run tests on VS Code, so in this blog we will walk you through the how. Meanwhile, we will share the news of releasing Azure Spring Cloud extension. The extension is for you to create, manage and deploy apps to Azure Spring Cloud, a fully-managed Azure Service jointly built and operated with VMware. Let’s start.
To run Java tests on VS Code, we recommend using Java Test Runner extension. Our Java Extension Pack also includes the extension. The extension support JUnit4, JUnit5 and TestNG frameworks.
When a project with test cases imported into VS Code, VS Code can automatically detect the test cases and get ready for you to run. There are a couple of options to run.
1. Running from Test Explorer
Test Explorer offers the most comprehensive support for testing. In addition to run cases individually, you can Run All Tests as shown below.
2. Running from JAVA PROJECT Explorer
JAVA PROJECT Explorer provides access to all project related functionality including testing. You can run tests at project level or at individual package or class level as demonstrated below.
3. Running from CodeLens
CodeLens is a VS Code feature that provides context-aware actions through link next to your code. When VS Code detects testing annotation in code, it will provide a link of “Run Test” and a link of “Debug Test” next to the annotation for you to quickly place an action without jumping out of your code. It’s a handy feature that allows you focusing on coding by minimizing context switch.
Accessing testing report
After running tests, VS Code generates a testing report for you. You can access the report through status bar as shown in demos above or using Command Palette by Ctrl+Shift+P to launch the palette and then typing “java show test report” to open the report.
Azure Spring Cloud extension and more
Microsoft just released Azure Spring Cloud extension. The extension is for you to create, manage and deploy apps to Azure Spring Cloud, a fully-managed Azure Service jointly built and operated with VMware. The release underlines that VS Code is not only good for tasks like editing, running, debugging and testing, but also provides a seamless end-to-end experience for working with services. For Java developers on Azure, extensions are also available for other services like Azure App Services, Azure Functions, and many more. Please refer to VC Code documentation for more details. Meanwhile, we welcome communities and companies to develop extensions for your services. Let us know if you need support.
- VS Code Java now supports referring envFile in launch.json for debugging.
- JAVA PROJECTS explorer now supports displaying file decorator just as File Explorer.
Try it out
Please don’t hesitate to give it a try! Your feedback and suggestions are very important to us and will help shape our product in future.
- Learn more about Java on Visual Studio Code.
- Explore our step by step Java Tutorials on Visual Studio Code.
Можно использовать котлин на vs code
I’m starting on automated test and recently connected my framework with a azure devops pipeline to run the test cases. Now I’m trying to connect the execution to the test plan that we have. Is this possible or am I trying to do an impossible here?
Thanks for the guide!
Hi Arturo, we would like to learn more details about your scenario. Would be possible for you to file a issue here? We can discuss further using the issue thread.