Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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,243 @@
/*******************************************************************************
* Copyright 2021 Espressif Systems (Shanghai) PTE LTD. All rights reserved.
* Use is subject to license terms.
*******************************************************************************/
package com.espressif.idf.ui.test.executable.cases.project;

import static org.junit.Assert.assertTrue;

import java.io.IOException;

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
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 com.espressif.idf.ui.test.common.utility.TestWidgetWaitUtility;
import com.espressif.idf.ui.test.operations.EnvSetupOperations;
import com.espressif.idf.ui.test.operations.ProjectTestOperations;

/**
* Test class to test the SBOM feature
*
* @author Andrii Filippov
*
*/
Comment on lines +25 to +30
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Update JavaDoc to reflect the correct purpose of the test class

The JavaDoc comment incorrectly states this is a test class for the "SBOM feature", but the class actually tests the Partition Table Editor functionality.

Apply this diff to correct the JavaDoc:

 /**
- * Test class to test the SBOM feature
+ * Test class to validate the Partition Table Editor functionality
  * 
  * @author Andrii Filippov
  *
  */
📝 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
/**
* Test class to test the SBOM feature
*
* @author Andrii Filippov
*
*/
/**
* Test class to validate the Partition Table Editor functionality
*
* @author Andrii Filippov
*
*/

@SuppressWarnings("restriction")
@RunWith(SWTBotJunit4ClassRunner.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
Comment on lines +32 to +33
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider removing test dependencies.

The use of @FixMethodOrder(MethodSorters.NAME_ASCENDING) suggests that tests are dependent on execution order. This is an anti-pattern in unit testing as it makes tests brittle and harder to maintain.

Consider:

  1. Making each test independent by setting up its own test state
  2. Using appropriate @Before methods for common setup
  3. Removing the @FixMethodOrder annotation once tests are independent

public class NewEspressifIDFProjectPartitionTableEditorTest
{
@BeforeClass
public static void beforeTestClass() throws Exception
{
Fixture.loadEnv();
}

Check warning on line 40 in tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].

@After
public void afterEachTest()
{
try
{
Fixture.cleanTestEnv(); // Make sure test environment is always cleaned up
}
catch (Exception e)
{
System.err.println("Error during cleanup: " + e.getMessage());
}
}

@Test
public void givenNewProjectCreatedNotBuiltWhenOpenEmptyPartitionTableEditorThenInformationPopUpMessage()
throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectPartitionTableEditor1Test");
Fixture.whenNewProjectIsSelected();
Fixture.whenOpenEmptyPartitionTableEditor();
Fixture.ThenInformationMessagePopUp();
}

Check warning on line 64 in tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].

@Test
public void givenNewProjectCreatedBuiltWhenOpenPartitionTableEditorThenBuiltInPartitionTableDisplayed()
throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectPartitionTableEditor2Test");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.whenOpenPartitionTableEditor();
Fixture.ThenBuiltInPartitionTableDisplayed();
}

Check warning on line 76 in tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].

@Test
public void givenNewProjectCreatedBuiltWhenOpenPartitionTableEditorWhenAddRowThenCheckRowAdded() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectPartitionTableEditor3Test");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.whenOpenPartitionTableEditor();
Fixture.whenAddRowToPartitionTable();
Fixture.ThenCheckRowAdded();
}

Check warning on line 88 in tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].

@Test
public void givenNewProjectCreatedBuiltWhenOpenPartitionTableEditorWhenDeleteSelectedRowThenCheckRowDeleted()
throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectPartitionTableEditor4Test");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.whenOpenPartitionTableEditor();
Fixture.whenDeleteRowFromPartitionTable();
Fixture.ThenCheckRowDeleted();
}

Check warning on line 101 in tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].

@Test
public void givenNewProjectCreatedBuiltWhenOpenPartitionTableEditorWhenDeleteSelectedRowWhenSaveAndQuitwhenReopenPartitionTableThenCheckChangesSaved()
throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectPartitionTableEditor5Test");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.whenOpenPartitionTableEditor();
Fixture.whenDeleteRowFromPartitionTable();
Fixture.whenSaveAndQuit();
Fixture.whenOpenPartitionTableEditor();
Fixture.thenCheckChangesSaved();
}

Check warning on line 116 in tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].

@Test
public void givenNewProjectCreatedBuiltWhenOpenPartitionTableEditorWhenDeleteSelectedRowWhenSaveAndCancelwhenReopenPartitionTableThenCheckChangesSaved()
throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectPartitionTableEditor6Test");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.whenOpenPartitionTableEditor();
Fixture.whenDeleteRowFromPartitionTable();
Fixture.whenSavePartitionTable();
Fixture.whenCancel();
Fixture.whenOpenPartitionTableEditor();
Fixture.thenCheckChangesSaved();
}

Check warning on line 132 in tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].

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);
}

Check warning on line 146 in tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].
Comment on lines +141 to +146
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid using fixed delays like bot.sleep(1000);

Using fixed delays can lead to flaky tests due to variable execution times. Instead, use explicit wait conditions provided by SWTBot to wait for specific UI elements or operations to complete.

Apply this diff to replace bot.sleep(1000); with a proper wait condition:

 private static void loadEnv() throws Exception
 {
     bot = WorkBenchSWTBot.getBot();
     EnvSetupOperations.setupEspressifEnv(bot);
-    bot.sleep(1000);
+    TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
 }
📝 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
private static void loadEnv() throws Exception
{
bot = WorkBenchSWTBot.getBot();
EnvSetupOperations.setupEspressifEnv(bot);
bot.sleep(1000);
}
private static void loadEnv() throws Exception
{
bot = WorkBenchSWTBot.getBot();
EnvSetupOperations.setupEspressifEnv(bot);
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(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);
}

Check warning on line 162 in tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].

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

private static void whenOpenPartitionTableEditor() throws IOException
{
ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Partition Table Editor");
TestWidgetWaitUtility.waitUntilDialogIsNotVisible(bot, "Partition Table Editor", 10000);
}
Comment on lines +171 to +175
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add proper wait conditions for UI interactions.

UI operations like opening editors and clicking buttons need proper wait conditions to prevent flaky tests.

Apply these improvements:

 private static void whenOpenPartitionTableEditor() throws IOException
 {
+    TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
     ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Partition Table Editor");
     TestWidgetWaitUtility.waitUntilDialogIsNotVisible(bot, "Partition Table Editor", 10000);
+    TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
 }

 private static void whenAddRowToPartitionTable() throws IOException
 {
+    TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
     bot.toolbarButton("Add Row").click();
+    TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
 }

Also applies to: 194-197


private static void whenOpenEmptyPartitionTableEditor() throws IOException
{
ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Partition Table Editor");
TestWidgetWaitUtility.waitUntilDialogIsNotVisible(bot, "Information", 10000);
}

private static void ThenInformationMessagePopUp() throws IOException
{
assertTrue(ProjectTestOperations.checkShellContent(bot, "Information",
"Failed to get partition CSV file name from sdkconfig. Make sure your project is compiled and has sdkconfig."));
}
Comment on lines +183 to +187
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Follow Java naming conventions for method names

Method names starting with uppercase letters don't follow Java naming conventions. Please update them to start with lowercase letters.

-private static void ThenInformationMessagePopUp()
+private static void thenInformationMessagePopUp()

-private static void ThenBuiltInPartitionTableDisplayed()
+private static void thenBuiltInPartitionTableDisplayed()

-private static void ThenCheckRowAdded()
+private static void thenCheckRowAdded()

-private static void ThenCheckRowDeleted()
+private static void thenCheckRowDeleted()

Also applies to: 181-184, 191-194, 201-204, 223-226


private static void ThenBuiltInPartitionTableDisplayed() throws IOException
{
assertTrue(ProjectTestOperations.checkPartitionTableContent(bot));
}

private static void whenAddRowToPartitionTable() throws IOException
{
bot.toolbarButton("Add Row").click();
}

private static void ThenCheckRowAdded() throws IOException
{
assertTrue(ProjectTestOperations.comparePartitionTableRows(bot, 1));
}
Comment on lines +194 to +202
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add retry mechanism for UI interactions.

UI interactions like clicking buttons and checking table contents can be flaky. Consider adding a retry mechanism with appropriate waits.

 private static void whenAddRowToPartitionTable() throws IOException
 {
+    TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
     bot.toolbarButton("Add Row").click();
+    TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
 }

 private static void ThenCheckRowAdded() throws IOException
 {
+    // Retry up to 3 times with a short delay
+    for (int i = 0; i < 3; i++) {
+        if (ProjectTestOperations.comparePartitionTableRows(bot, 1)) {
+            return;
+        }
+        TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
+    }
     assertTrue(ProjectTestOperations.comparePartitionTableRows(bot, 1));
 }
📝 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
private static void whenAddRowToPartitionTable() throws IOException
{
bot.toolbarButton("Add Row").click();
}
private static void ThenCheckRowAdded() throws IOException
{
assertTrue(ProjectTestOperations.comparePartitionTableRows(bot, 1));
}
private static void whenAddRowToPartitionTable() throws IOException
{
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
bot.toolbarButton("Add Row").click();
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
}
private static void ThenCheckRowAdded() throws IOException
{
// Retry up to 3 times with a short delay
for (int i = 0; i < 3; i++) {
if (ProjectTestOperations.comparePartitionTableRows(bot, 1)) {
return;
}
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
}
assertTrue(ProjectTestOperations.comparePartitionTableRows(bot, 1));
}


private static void whenDeleteRowFromPartitionTable() throws IOException
{
ProjectTestOperations.deletePartitionTableRow(bot);
}

private static void ThenCheckRowDeleted() throws IOException
{
assertTrue(ProjectTestOperations.comparePartitionTableRows(bot, -1));
}

private static void whenSaveAndQuit() throws IOException
{
bot.button("Save and Quit").click();
bot.button("OK").click();
}

private static void whenSavePartitionTable() throws IOException
{
bot.toolbarButton("Save").click();
bot.button("OK").click();
}

private static void whenCancel() throws IOException
{
bot.button("Cancel").click();
}

private static void thenCheckChangesSaved() throws IOException
{
assertTrue(ProjectTestOperations.comparePartitionTableRows(bot, -1));
}

private static void cleanTestEnv()
{
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
ProjectTestOperations.closeAllProjects(bot);
ProjectTestOperations.deleteAllProjects(bot);
}
Comment on lines +236 to +241
Copy link

Choose a reason for hiding this comment

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

Handle potential exceptions within the method.

The cleanTestEnv method currently does not handle potential exceptions. Consider adding exception handling to ensure the test environment is cleaned up properly even if an error occurs.

private static void cleanTestEnv() {
	try {
		TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
		ProjectTestOperations.closeAllProjects(bot);
		ProjectTestOperations.deleteAllProjects(bot);
	} catch (Exception e) {
		// Log the exception and proceed with cleanup
		e.printStackTrace();
	}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
@BeforeClass
public static void beforeTestClass() throws Exception
{
Fixture.loadEnv();
}

Check warning on line 59 in tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].

@After
public void afterEachTest()
Expand All @@ -67,58 +67,57 @@
@Test
public void givenNewIDFProjectIsSelectedThenProjectIsCreatedAndAddedToProjectExplorer() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectTest");
Fixture.whenNewProjectIsSelected();
Fixture.thenProjectIsAddedToProjectExplorer();

}

Check warning on line 74 in tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].

@Test
public void givenNewIDFProjectIsSelectedFromTemplateThenProjectIsCreatedAndAddedToProjectExplorerWithRequiredFiles()
throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectTestTemplate");
Fixture.givenProjectTemplateIs("bluetooth/esp_hid_device");
Fixture.whenProjectIsCreatedFromTemplate();
Fixture.thenProjectIsAddedToProjectExplorer();
Fixture.thenProjectHasTheFile("esp_hid_device_main.c", "/main");
Fixture.thenProjectHasTheFile("esp_hid_gap.c", "/main");
Fixture.thenProjectHasTheFile("esp_hid_gap.h", "/main");
}

Check warning on line 88 in tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].

@Test
public void givenNewIDFProjectIsCreatedAndBuiltUsingContextMenuOnProjectThenProjectIsCreatedAndBuilt()
throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectForContextMenuBuildTest");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.thenConsoleShowsBuildSuccessful();
}

Check warning on line 99 in tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].

@Test
public void givenNewIDFProjectIsCreatedAndBuiltUsingToolbarButtonThenProjectIsBuilt() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectToolbarBuildButtonTest");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.thenConsoleShowsBuildSuccessful();
}

Check warning on line 109 in tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].

@Test
public void givenNewProjectCreatedAndRenamedAfterThenProjectIsBuildSuccessfully() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectForRenameTest");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsRenamed("NewProjectForRenameTest2");
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.thenConsoleShowsBuildSuccessful();
}

Check warning on line 120 in tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].

// @Test
// public void givenNewProjectCreatedDfuBuiltThenHasDfuBin() throws Exception
Expand All @@ -136,14 +135,14 @@
@Test
public void givenNewProjectCreatedThenInstallNewComponent() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectForInstallNewComponentTest");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.whenInstallNewComponentUsingContextMenu();
Fixture.whenRefreshProject();
Fixture.checkIfNewComponentIsInstalledUsingContextMenu();
}

Check warning on line 145 in tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].

// @Test
// public void givenNewProjectCreatedBuiltAndThenProjectCleanUsingContextMenu() throws Exception
Expand All @@ -160,25 +159,25 @@
@Test
public void givenNewProjectCreatedBuiltAndThenProjectFullCleanUsingContextMenu() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectFullCleanTest");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.whenProjectFullCleanUsingContextMenu();
Fixture.whenRefreshProject();
Fixture.checkIfProjectFullCleanedFilesInBuildFolder();
}

Check warning on line 169 in tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].

@Test
public void givenNewProjectCreatedBuiltAndThenProjectPythonCleanUsingContextMenu() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectPythonCleanTest");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.whenProjectPythonCleanUsingContextMenu();
Fixture.checkPythonCLeanCommandDeleteFolder();
}

Check warning on line 180 in tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].

private static class Fixture
{
Expand All @@ -192,21 +191,21 @@

private static void loadEnv() throws Exception
{
bot = WorkBenchSWTBot.getBot();
EnvSetupOperations.setupEspressifEnv(bot);
bot.sleep(1000);
ProjectTestOperations.deleteAllProjects(bot);
launchBarConfigSelector = new LaunchBarConfigSelector(bot);
try
{
launchBarTargetSelector = new LaunchBarTargetSelector(bot);
}
catch (WidgetNotFoundException e)
{
launchBarTargetSelector = new LaunchBarTargetSelector(bot, false);
}

}

Check warning on line 208 in tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].

public static void thenLaunchTargetIsSelectedFromLaunchTargets(String launchTargetName)
{
Expand Down Expand Up @@ -242,9 +241,9 @@

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

Check warning on line 246 in tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].

public static void turnOffDfu()
{
Expand All @@ -270,7 +269,7 @@

private static void whenInstallNewComponentUsingContextMenu() throws IOException
{
ProjectTestOperations.openProjectNewComponentUsingContextMenu(projectName, bot);
ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Install New Component");
bot.editorByTitle(projectName).show();
bot.button("Install").click();
ProjectTestOperations.waitForProjectNewComponentInstalled(bot);
Expand Down Expand Up @@ -335,13 +334,10 @@
}
}

private static void thenConsoleShowsBuildSuccessful()
private static void thenConsoleShowsBuildSuccessful() throws IOException
{
SWTBotView consoleView = ProjectTestOperations.viewConsole("CDT Build Console", bot);
consoleView.show();
consoleView.setFocus();
String consoleTextString = consoleView.bot().styledText().getText();
assertTrue(consoleTextString.contains("Build complete (0 errors"));
ProjectTestOperations.findInConsole(bot, "CDT Build Console [" + Fixture.projectName + "]",
"Build complete (0 errors");
}

private static void cleanTestEnv()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;

import com.espressif.idf.core.util.IDFUtil;
import com.espressif.idf.ui.test.common.configs.DefaultPropertyFetcher;
import com.espressif.idf.ui.test.common.utility.TestWidgetWaitUtility;

Expand All @@ -22,73 +20,66 @@

public static void setupEspressifEnv(SWTWorkbenchBot bot) throws Exception
{
if (SETUP)
return;

for (SWTBotView view : bot.views(withPartName("Welcome")))
{
view.close();
}
bot.menu("Window").menu("Perspective").menu("Open Perspective").menu("Other...").click();
bot.table().select("C/C++");
bot.button("Open").click();

bot.menu("Window").menu("Preferences").click();
SWTBotShell prefrencesShell = bot.shell("Preferences");

prefrencesShell.bot().tree().getTreeItem("General").select();
prefrencesShell.bot().tree().getTreeItem("General").expand();
prefrencesShell.bot().tree().getTreeItem("General").getNode("Editors").select();
prefrencesShell.bot().tree().getTreeItem("General").getNode("Editors").expand();
prefrencesShell.bot().tree().getTreeItem("General").getNode("Editors").getNode("File Associations").select();
prefrencesShell.bot().comboBox().setSelection("Text Editor");
prefrencesShell.bot().tree().getTreeItem("General").getNode("Workspace").select();
if (!prefrencesShell.bot().checkBox("Refresh using native hooks or polling").isChecked())
{
prefrencesShell.bot().checkBox("Refresh using native hooks or polling").click();
}

prefrencesShell.bot().tree().getTreeItem("C/C++").select();
prefrencesShell.bot().tree().getTreeItem("C/C++").expand();
prefrencesShell.bot().tree().getTreeItem("C/C++").getNode("Indexer").select();
if (prefrencesShell.bot().checkBox("Enable indexer").isChecked())
{
prefrencesShell.bot().checkBox("Enable indexer").click();
}

prefrencesShell.bot().button("Apply and Close").click();

bot.toolbarButtonWithTooltip("Select and deselect filters to apply to the content in the tree").click();
bot.table().getTableItem(".* resources").uncheck();
bot.button("OK").click();

bot.menu("Window").menu("Show View").menu("Other...").click();
bot.text().setText("progress");
bot.button("Open").click();
bot.viewByTitle("Progress").show();

TestWidgetWaitUtility.waitForOperationsInProgressToFinishSync(bot);
bot.activeShell();

bot.menu("Espressif").menu("ESP-IDF Manager").click();
bot.activeShell().activate();
bot.button("Add ESP-IDF").click();
SWTBotShell espIdfConfigShell = bot.shell("ESP-IDF Configuration");
espIdfConfigShell.setFocus();
espIdfConfigShell.bot().checkBox("Use an existing ESP-IDF directory from file system").click();
espIdfConfigShell.bot().textWithLabel("Choose existing ESP-IDF directory:")
.setText(DefaultPropertyFetcher.getStringPropertyValue(ESP_IDF_PATH_PROPERTY, ""));
espIdfConfigShell.bot().textWithLabel("Git: ")
.setText(DefaultPropertyFetcher.getStringPropertyValue(GIT_PATH_PROPERTY, ""));
espIdfConfigShell.bot().textWithLabel("Python: ")
.setText(DefaultPropertyFetcher.getStringPropertyValue(PYTHON_PATH_PROPERTY, ""));
espIdfConfigShell.bot().button("Finish").click();

SWTBotView consoleView = bot.viewById("org.eclipse.ui.console.ConsoleView");
consoleView.show();
consoleView.setFocus();
TestWidgetWaitUtility.waitUntilViewContains(bot, "Tools Activated", consoleView, 99000000);
bot.cTabItem("ESP-IDF Manager").activate();
bot.cTabItem("ESP-IDF Manager").close();
SETUP = true;
}

Check warning on line 83 in tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/EnvSetupOperations.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].

}
Loading
Loading