Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
/*******************************************************************************
* Copyright 2025 Espressif Systems (Shanghai) PTE LTD.
* All rights reserved. Use is subject to license terms.
*******************************************************************************/

package com.espressif.idf.ui.test.executable.cases.project;

import java.io.IOException;

import org.apache.commons.lang3.SystemUtils;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;

import com.espressif.idf.ui.test.common.WorkBenchSWTBot;
import static org.eclipse.swtbot.swt.finder.waits.Conditions.*;
import static org.junit.Assert.assertTrue;

import com.espressif.idf.ui.test.common.utility.TestWidgetWaitUtility;
import com.espressif.idf.ui.test.operations.EnvSetupOperations;
import com.espressif.idf.ui.test.operations.ProjectTestOperations;
import com.espressif.idf.ui.test.operations.selectors.LaunchBarConfigSelector;
import com.espressif.idf.ui.test.operations.selectors.LaunchBarTargetSelector;

/**
* Test class to test Debug Process
*
* @author Andrii Filippov
*
*/

@SuppressWarnings("restriction")
@RunWith(SWTBotJunit4ClassRunner.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class IDFProjectDebugProcessTest
{
@BeforeClass
public static void beforeTestClass() throws Exception
{
Fixture.loadEnv();
}

@After
public void afterEachTest()
{
try
{
Fixture.cleanTestEnv();
}
catch (Exception e)
{
System.err.println("Error during cleanup: " + e.getMessage());
}
}

@Test
public void givenNewProjectCreatedWhenFlashedAndDebuggedThenDebuggingWorks() throws Exception
{
if (SystemUtils.IS_OS_LINUX) //temporary solution until new ESP boards arrive for Windows
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Category label typo will break the wizard selection

"EspressIf" should be "Espressif" to match the UI category and avoid widget lookup failures.

-            Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
+            Fixture.givenNewEspressifIDFProjectIsSelected("Espressif", "Espressif IDF Project");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenNewEspressifIDFProjectIsSelected("Espressif", "Espressif IDF Project");
🤖 Prompt for AI Agents
In
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectDebugProcessTest.java
around line 72, the category label string passed to
Fixture.givenNewEspressifIDFProjectIsSelected is misspelled as "EspressIf";
replace it with the correct UI category "Espressif" so the wizard/widget lookup
matches the UI and selection succeeds.

Fixture.givenProjectNameIs("NewProjecDebugTest");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Typo in project name.

There's a spelling error in the project name: "NewProjecDebugTest" should be "NewProjectDebugTest".

Apply this diff to fix the typo:

-Fixture.givenProjectNameIs("NewProjecDebugTest");
+Fixture.givenProjectNameIs("NewProjectDebugTest");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Fixture.givenProjectNameIs("NewProjecDebugTest");
Fixture.givenProjectNameIs("NewProjectDebugTest");
🤖 Prompt for AI Agents
In
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectDebugProcessTest.java
around line 69, the project name string has a typo "NewProjecDebugTest"; update
the string literal to "NewProjectDebugTest" so the fixture uses the correctly
spelled project name.

Fixture.whenNewProjectIsSelected();
Fixture.whenTurnOffOpenSerialMonitorAfterFlashingInLaunchConfig();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.whenSelectLaunchTargetSerialPort();
Fixture.whenFlashProject();
Fixture.thenVerifyFlashDoneSuccessfully();
Fixture.whenSelectDebugConfig();
Fixture.whenSelectLaunchTargetBoard();
// Fixture.whenDebugProject();
// Fixture.whenSwitchPerspective();
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Incomplete test implementation with commented debug steps.

The core debugging functionality is commented out, which means this test doesn't fully validate the debugging workflow as described in the PR objectives. The test stops at configuration selection rather than actual debugging verification.

The PR description mentions verifying "the match of the project name, Actual Executable, and SVD Path in the New ESP-IDF GDB OpenOCD Debugging Launch Configuration", but the actual debugging verification steps are commented out. Can you confirm whether this is intentional for this iteration, or if the debugging steps should be implemented to meet the PR objectives?


🏁 Script executed:

#!/bin/bash
# Search for any other debug-related test implementations that might provide guidance
rg -n "Debug.*Configuration" --type=java -C 3

Length of output: 45763


Test selects the debug config but does not verify or launch it — implement verification or clarify intent

  • The commented calls (Fixture.whenDebugProject / Fixture.whenSwitchPerspective at tests/.../IDFProjectDebugProcessTest.java) appear to be replaced by helper code: whenDebugProject() in tests/com.espressif.idf.ui.test/.../IDFProjectDebugProcessTest.java (≈lines 124–131) and ProjectTestOperations.createDebugConfiguration(...) in tests/com.espressif.idf.ui.test/.../ProjectTestOperations.java (≈lines 124–135); both only open/select the "ESP‑IDF GDB OpenOCD Debugging" node.
  • There is no evidence these helpers click "Debug" or assert the PR-required fields ("project name", "Actual Executable", "SVD Path"). Implement assertions (or start the debug and inspect the launch configuration) to meet the PR objective, or update the PR to state that full debug verification is intentionally omitted.
🤖 Prompt for AI Agents
In
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectDebugProcessTest.java
around lines 78–80, the test selects the "ESP‑IDF GDB OpenOCD Debugging" node
but never verifies or launches the debug configuration; update the test to
either (A) assert the selected launch configuration's required fields (validate
the launch config name/project name, Actual Executable path, and SVD Path) by
retrieving the ILaunchConfiguration (or equivalent helper) and asserting those
properties, or (B) actually start the debug launch and assert the expected
debugger/launch behavior; alternatively, if full verification is intentionally
omitted, update the PR description and test comments to state that deliberate
omission. Ensure new assertions fail on missing/incorrect values and keep helper
usage in ProjectTestOperations or whenDebugProject() to obtain the selected
configuration.

else
{
assertTrue(true);
}
}

private static class Fixture
{
private static SWTWorkbenchBot bot;
private static String category;
private static String subCategory;
private static String projectName;

private static void loadEnv() throws Exception
{
bot = WorkBenchSWTBot.getBot();
EnvSetupOperations.setupEspressifEnv(bot);
bot.sleep(1000);
ProjectTestOperations.deleteAllProjects(bot);
}

private static void givenNewEspressifIDFProjectIsSelected(String category, String subCategory)
{
Fixture.category = category;
Fixture.subCategory = subCategory;
}

private static void givenProjectNameIs(String projectName)
{
Fixture.projectName = projectName;
}

private static void whenNewProjectIsSelected() throws Exception
{
ProjectTestOperations.setupProject(projectName, category, subCategory, bot);
}

private static void whenProjectIsBuiltUsingContextMenu() throws IOException
{
ProjectTestOperations.buildProjectUsingContextMenu(projectName, bot);
ProjectTestOperations.waitForProjectBuild(bot);
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
}

private static void whenDebugProject() throws IOException
{
ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Debug Configurations...");
TestWidgetWaitUtility.waitForDialogToAppear(bot, "Debug Configurations", 10000);
bot.tree().getTreeItem("ESP-IDF GDB OpenOCD Debugging").select();
bot.tree().getTreeItem("ESP-IDF GDB OpenOCD Debugging").expand();
bot.tree().getTreeItem("ESP-IDF GDB OpenOCD Debugging").getNode(projectName + " Debug").select();
bot.waitUntil(widgetIsEnabled(bot.button("Debug")), 5000);
bot.button("Debug").click();
}

private static void whenSelectDebugConfig() throws Exception
{
LaunchBarConfigSelector configSelector = new LaunchBarConfigSelector(bot);
configSelector.select(projectName + " Debug");
}

private static void whenSelectLaunchTargetBoard() throws Exception
{
LaunchBarTargetSelector targetSelector = new LaunchBarTargetSelector(bot);
targetSelector.clickEdit();
TestWidgetWaitUtility.waitForDialogToAppear(bot, "New ESP Target", 20000);
SWTBotShell shell = bot.shell("New ESP Target");
bot.comboBoxWithLabel("Board:").setSelection("ESP32-ETHERNET-KIT [usb://1-10]");
TestWidgetWaitUtility.waitForOperationsInProgressToFinishSync(bot);
shell.setFocus();
bot.button("Finish").click();
}

private static void whenSwitchPerspective() throws Exception
{
TestWidgetWaitUtility.waitForDialogToAppear(bot, "Confirm Perspective Switch", 20000);
bot.button("Switch").click();
}

private static void whenTurnOffOpenSerialMonitorAfterFlashingInLaunchConfig() throws Exception
{
LaunchBarConfigSelector configSelector = new LaunchBarConfigSelector(bot);
configSelector.clickEdit();
TestWidgetWaitUtility.waitForDialogToAppear(bot, "Edit Configuration", 20000);
bot.cTabItem("Main").show();
bot.cTabItem("Main").setFocus();
SWTBotCheckBox checkBox = bot.checkBox("Open Serial Monitor After Flashing");
if (checkBox.isChecked()) {
checkBox.click();
}
bot.button("OK").click();
}

private static void whenSelectLaunchTargetSerialPort() throws Exception
{
LaunchBarTargetSelector targetSelector = new LaunchBarTargetSelector(bot);
targetSelector.clickEdit();
TestWidgetWaitUtility.waitForDialogToAppear(bot, "New ESP Target", 20000);
SWTBotShell shell = bot.shell("New ESP Target");
bot.comboBoxWithLabel("Serial Port:").setSelection("/dev/ttyUSB1 Dual RS232-HS");
TestWidgetWaitUtility.waitForOperationsInProgressToFinishSync(bot);
shell.setFocus();
bot.button("Finish").click();
}

private static void whenFlashProject() throws IOException
{
ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Run Configurations...");
TestWidgetWaitUtility.waitForDialogToAppear(bot, "Run Configurations", 10000);
bot.tree().getTreeItem("ESP-IDF Application").select();
bot.tree().getTreeItem("ESP-IDF Application").expand();
bot.tree().getTreeItem("ESP-IDF Application").getNode(projectName).select();
bot.waitUntil(widgetIsEnabled(bot.button("Run")), 5000);
bot.button("Run").click();
}

private static void thenVerifyFlashDoneSuccessfully() throws Exception
{
ProjectTestOperations.waitForProjectFlash(bot);
}

private static void cleanTestEnv()
{
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
ProjectTestOperations.closeAllProjects(bot);
ProjectTestOperations.deleteAllProjects(bot);
}
}
}
Loading