Running external processes, tests or apps (Java main methods) is supported using Bazel Launch Configurations.
The IDE delegates to "bazel run" to run Java main methods. Therefore your main
method must be backed by a runnable Bazel target type. Currently, only java_binary
is supported.
Example:
If you have a Bazel target in your BUILD file that looks like this:
java_binary(
name = "fruit-salad-service",
main_class = "demo.salesforce.salad.FruitSalad",
...
)
You can run FruitSalad
's main method by creating a launch configuration:
- Navigate to Run Configurations...
- Create a new instance of the Bazel Target launcher
- Identify the project and java_binary target
You should now be able to run the fruit-salad-service
app.
You can also debug it, with breakpoints, by launching as a Debug Configuration.
There are several paths to run (or debug) tests from BEF.
Method 1: top level Run menu
- Navigate to the Run menu, choose Run As... and click the New button for Bazel Target
- Select the project, and then the test target from the drop down.
- You should now be able to run the test.
You can also debug it, with breakpoints, by launching as a Debug Configuration.
Method 2: Package Explorer context menu
- In the Package Explorer view, click on the test folder (src/test/java), a test Java package (com.salesforce.hello), or a specific test class (HelloWorldTest.java)
- Right click on it, and find the Run As or Debug As item in the context menu
- Choose JUnit Bazel Target
- The JUnit view will populate with the test results
This is the end of the step by step user guide. At this point you have hopefully imported your Bazel workspace and are ready to develop.
Please press the 'star' button at the top of this page if you have not already done so. This helps us get more time and resources for this project.
If you have problems using BEF, please file an Issue and we will try to help you.