Test Class Breakpoint does not stop

Answered

When I add breakpoints to my Junit 5, works with TestNG, test cases the debugger doesn't stop on them. Breakpoints in my main code or third party code does cause the debugger to stop and I can then step through my test.  

 

Junit Jupiter 5.2.0

Java JDK 1.8.0_181

IntelliJ IDEA 2018.2 (Ultimate Edition)
Build #IU-182.3684.101, built on July 24, 2018


JRE: 1.8.0_152-release-1248-b8 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.13.3

0
13 comments

Can you provide a sample project to check?

What Run/Debug Configuration do you use for debugging, please attach screenshot. Do you build by IDE or external build tool (Maven/Gradle)? Try Build | Rebuild action. Also make sure the code where you set a breakpoint is actually executing.

0
Avatar
Permanently deleted user

Hi! 

I have pretty much the same problem on my end here! I'm just starting web development, so I'm not super solid on specifics, but I know Im using Spring, Maven, Tomcat (for the server) and html for the views (but I assume thats not really relevant?). The version is IntelliJ IDEA 2019.2, NOT the community version, I got the download with my college.

The test was working normaly a while back (a day or so). I changed a couple of things in the test function code, so maybe that cause it? But I don't think so.

I send screenshots with the problem. Sorry if it's a little confusing, as my variable names and such are all in portuguese.

The way Im trying to run this test is by pressing the little green start button on image 1, then clicking "debug "Mensagem()" ".

When I hover over the breakpoint that is now a "can't" symbol (as seen in image 2), it says :"No executable code found at line <the line where the breakpoint is> in class <the test class>". Which, for me, doesn't really make sense to me? How is the code not executable when Im calling a funtion in it?

Adicionally, I've had some weird problems before with the IDEA not recognizing some classes in the same project/namespace. Reeinporting the files seemed to do the trick.

Thanks either way.

0

Hello Philemon,

Please clarify if the test runs successfully for you if you run it (not debug) with IntelliJ IDEA? Can you please share the sample project (you may create an issue at YouTrack (https://youtrack.jetbrains.com/issue) attaching the project to it). Thank you

0

Same problem here 

IntelliJ IDEA 2018.3.3 (Ultimate Edition)
Build #IU-183.5153.38, built on January 9, 2019
Licensed to IHS Global

JRE: 1.8.0_152-release-1343-b26 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

 

The breakpoint in the test_002_USER_200aws_ems_energy_intl_well_denuk_ihs_com() does not work, however the breakpoint in the setup() method works!

 

 

Full testcase code:

package com.ihs.securitymanager.accesscontrol;


import com.ihs.securitymanager.accesscontrol.adapter.AccessControl;
import com.ihs.securitymanager.accesscontrol.bootstrap.ConfigurationHandler;
import de.conterra.suite.policy.common.usermanagement.adapter.IRoleManager;
import de.conterra.suite.policy.common.usermanagement.adapter.IUserInfo;
import org.junit.jupiter.api.*;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

@TestMethodOrder(AlphabeticalTestNameOrderer.class)
public class ACAdapterUserEntitlementTestCase {




private static ApplicationContext appContext;
private static AccessControl adapter;
private static IRoleManager roleManager;
private static TestUserManager testUserManager;
private static ConfigurationHandler adapterConfiguration;
private static boolean runTestCase = false;

private static boolean isInUnitTestMode;




@BeforeAll
static void setup()
{
testUserManager = new TestUserManager();

appContext = new ClassPathXmlApplicationContext("classpath:./spring-accesscontrol-config.xml");

adapter = (AccessControl) appContext.getBean("acUserManager");
roleManager = adapter.getRoleManager();
adapterConfiguration = adapter.getIhsUserManager().getConfiguration();


isInUnitTestMode = adapterConfiguration.isUnitTestMode();

System.out.println("setup() executed");
}


@Test
public void test_001_check_roles() throws Exception {

if (runTestCase && isInUnitTestMode) {
Assertions.assertTrue(roleManager.getRoles().length >= 10, "Less than 10 roles/NimsAC product codes.");
}
}


@Test
public void test_002_USER_200aws_ems_energy_intl_well_denuk_ihs_com() throws Exception {

if (runTestCase && isInUnitTestMode) {
String userName = "200aws-ems-energy.intl.well-denuk@ihs.com";
IUserInfo user = adapter.loginUser(userName, testUserManager.getStageUsers().get(userName));
Assertions.assertTrue(user.getUserAttributes().length >=2, "This user is expected to have more than two user attribute(complex entitlement attribute).");
}
}




@AfterAll
static void tear(){
System.out.println("tear() executed");
}

}

 

 

0

Hello Nielsen, if possible please check if you experience the same issue with the latest IntelliJ IDEA available (2019.2.2): https://www.jetbrains.com/idea/download

If the issue is still reproduced please create an issue at YouTrack providing the little sample project (https://youtrack.jetbrains.com).

Thank you

0

it works with:

 

IntelliJ IDEA 2019.2.2 (Ultimate Edition)
Build #IU-192.6603.28, built on September 6, 2019
Licensed to IHS Global

Runtime version: 11.0.3+12-b304.56 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 725M
Cores: 12
Registry:
Non-Bundled Plugins: com.microsoft.vso.idea

 

0

Nielsen, thank you for confirming it works correct now!

0

I have the same issue. The 2021 version of Intellij wouldn't stop at break point when running test methods (JUnit)

I did not have an issue later when I downloaded 2022 Intellij comunity edition.

Now I have the ISSUE AGAIN with 2023 version.

Please advise

0

Hi Pakan Prsd 

Please submit a new ticket to YouTrack and make sure to include this info:

1. An actual example with screenshots (or better yet, a small demo project)

2. Exact steps to reproduce the issue

3. A screenshot of the Run/Debug Configuration used for debugging

4. Contents of your Help | About window

0

The same issue here I updated IDEA to the last version.

IntelliJ IDEA 2025.1.2 (Ultimate Edition)
Build #IU-251.26094.121, built on June 3, 2025

0

Hi Oleg Zavrazhin - please follow the steps from this comment to submit your problem for further analysis.

0

Hello @....
I created the issue 3 days ago, no answer so far.
I know it might take some time. However, It's blocking me I got used ot rely on things like “functioning breakpoints” in IDEA.
It's kinda disappointing.

0
Hi Oleg,
Thanks for your patience.
My colleague Gabriel has just replied to you in the issue with his findings and further questions. Please have a look.
https://youtrack.jetbrains.com/issue/IDEA-374757#focus=Comments-27-12237636.0-0
0

Please sign in to leave a comment.