Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SWTBot test case: Partition Table Editor #1012

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Conversation

AndriiFilippov
Copy link
Collaborator

@AndriiFilippov AndriiFilippov commented Jul 1, 2024

Description

add Partition Table Editor test cases.

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • PR Self Reviewed
  • Applied Code formatting
  • Added Documentation
  • Added Unit Test
  • Verified on all platforms - Windows,Linux and macOS

Summary by CodeRabbit

  • Tests
    • Introduced multiple new automated tests for validating the creation and management of new Espressif IDF projects.
    • Enhanced existing methods for installing new components by streamlining the command execution process.
    • Added tests for the Partition Table Editor, covering various scenarios including adding, deleting, and saving rows.
    • Improved overall test coverage with additional methods for verifying project creation and component installation functionalities.
    • Updated environment setup to simplify the process and enhance user interface interactions.
    • Reduced timeout for project build wait logic to improve efficiency.

Copy link

coderabbitai bot commented Jul 1, 2024

Walkthrough

The changes introduce multiple new test methods to the NewEspressifIDFProjectTest class, aimed at validating the creation and management of new Espressif IDF projects. Each new test method is a variant of existing ones, differentiated by a numeric suffix. Additionally, the whenInstallNewComponentUsingContextMenu() method is modified to streamline the installation process of new components. A new test class for the Partition Table Editor is added, along with modifications to the EnvSetupOperations and ProjectTestOperations classes to enhance functionality and simplify the setup process.

Changes

Files Change Summary
tests/com.espressif.idf.ui.test/.../NewEspressifIDFProjectTest.java Added ten new test methods to validate various aspects of creating and managing new IDF projects. Modified whenInstallNewComponentUsingContextMenu() to replace openProjectNewComponentUsingContextMenu() with launchCommandUsingContextMenu().
tests/com.espressif.idf.ui.test/.../NewEspressifIDFProjectPartitionTableEditorTest.java Added a new test class to validate the functionality of the Partition Table Editor with multiple test scenarios.
tests/com.espressif.idf.ui.test/.../EnvSetupOperations.java Removed C/C++ indexer configuration code and added lines to activate and close the "ESP-IDF Manager" tab.
tests/com.espressif.idf.ui.test/.../ProjectTestOperations.java Modified waitForProjectBuild method, removed openProjectNewComponentUsingContextMenu, and added four new methods for shell and partition table operations.
tests/pom.xml Updated memory allocation settings for the tycho-surefire-plugin in the project’s POM file.

Possibly related PRs

Suggested reviewers

  • kolipakakondal

Poem

In the land of code where rabbits play,
New tests hop in, brightening the day.
Projects created, cleaned with glee,
In Espressif's world, we're wild and free.
With every method, a leap we take,
For every test, a new path we make! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c009d36 and 2c6af85.

📒 Files selected for processing (2)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (3 hunks)
  • tests/pom.xml (1 hunks)
🔇 Additional comments (5)
tests/pom.xml (1)

33-33: Verify the necessity of high memory allocation

The significant increase in JVM memory allocation (-Xms4096m -Xmx8192m) raises some concerns:

  1. Such high memory requirements (4-8GB) might be problematic on CI systems or developer machines with limited resources
  2. This could mask potential memory leaks or inefficient test design

Let's analyze the memory usage patterns:

Consider:

  1. Adding memory usage monitoring to identify if tests actually require this much memory
  2. Implementing platform-specific memory configurations in the profiles section
  3. Investigating if test cleanup can be improved to reduce memory footprint
✅ Verification successful

Let me gather more information about the test complexity and memory usage patterns.


Based on the analysis of the test content and memory settings, I can now provide a final response:

High memory allocation is justified for these UI tests

The memory requirements (4-8GB) are reasonable considering:

  • Tests create and build multiple Eclipse projects in sequence
  • Complex UI automation involving Partition Table Editor operations
  • Each test case involves heavy operations:
    • Project creation
    • Full project builds
    • UI editor interactions
    • Multiple save/reload cycles
  • Proper cleanup is implemented via @After methods
  • Tests run in the Eclipse IDE workbench, which itself has significant memory overhead

The memory settings appear to be the only instance in the codebase, specifically tailored for these UI tests, and the implementation shows careful resource management through proper test cleanup.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for similar memory configurations in other test modules
# and analyze test class complexity

# Check for memory settings in other pom.xml files
echo "Checking other pom.xml files for memory settings:"
find . -name "pom.xml" -type f -exec grep -l "argLine" {} \;

# Analyze test complexity
echo -e "\nAnalyzing test complexity:"
# Look for SWTBot test classes
find . -type f -name "*Test.java" -exec grep -l "SWTBot" {} \;

Length of output: 932


Script:

#!/bin/bash
# Check the content of the partition table editor test to understand complexity
echo "Analyzing Partition Table Editor Test content:"
cat "./tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java"

# Check historical memory settings
echo -e "\nChecking historical memory settings:"
cat "./tests/pom.xml" | grep -A 2 -B 2 "argLine"

# Look for test setup/teardown patterns that might affect memory
echo -e "\nAnalyzing test setup/teardown patterns:"
ast-grep --pattern 'class $_ {
  $$$
  @Before
  $$$
  @After
  $$$
}'

Length of output: 8540

tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (4)

584-591: Handle potential exceptions in checkShellContent

The method may throw a WidgetNotFoundException if the shell or label with the expected text is not found.

This issue was previously identified. Please refer to the existing review comment for the suggested fix.


593-619: Correct the condition and loop order in checkPartitionTableContent

The method has issues with the logical operator in the condition and inefficient loop order.

This issue was previously identified. Please refer to the existing review comment for the suggested fix.


629-635: Add validation in deletePartitionTableRow

The method should validate that the table has enough rows before attempting to delete.

This issue was previously identified. Please refer to the existing review comment for the suggested fix.


88-91: Consider the impact of reduced timeout on slow builds.

The build wait timeout has been reduced from 600,000ms to 300,000ms. This might cause issues with slower builds, especially on resource-constrained systems or complex projects.

Consider making this timeout configurable through a system property or configuration file to accommodate different build environments.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3321cc0 and f64ad58.

Files selected for processing (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (1 hunks)
Additional comments not posted (6)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (6)

35-38: Specify a more specific exception type.

The beforeTestClass method currently throws a generic Exception. It's better to specify a more specific exception type to improve readability and error handling.

-	public static void beforeTestClass() throws Exception
+	public static void beforeTestClass() throws IOException

55-60: Make the sleep duration configurable or add a comment.

The loadEnv method includes a sleep duration of 1000 milliseconds. Consider making this duration configurable or adding a comment to explain its necessity.

-	bot.sleep(1000);
+	bot.sleep(1000); // Sleep to ensure the environment is fully set up

OR

private static final int SLEEP_DURATION = 1000;

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

62-66: LGTM!

The method givenNewEspressifIDFProjectIsSelected is correctly implemented.


68-71: LGTM!

The method givenProjectNameIs is correctly implemented.


73-76: LGTM!

The method whenNewProjectIsSelected is correctly implemented.


78-83: LGTM!

The method whenProjectIsBuiltUsingContextMenu is correctly implemented.

Comment on lines 41 to 46
public void afterEachTest()
{
Fixture.cleanTestEnv();
}
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 afterEachTest 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.

@After
public void afterEachTest() {
	try {
		Fixture.cleanTestEnv();
	} catch (Exception e) {
		// Log the exception and proceed with cleanup
		e.printStackTrace();
	}
}

Comment on lines +85 to +226
private static void cleanTestEnv()
{
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
ProjectTestOperations.closeAllProjects(bot);
ProjectTestOperations.deleteAllProjects(bot);
}
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();
	}
}

@kolipakakondal
Copy link
Collaborator

@alirana01 please review this

@AndriiFilippov AndriiFilippov changed the title SWTBot test case: Partition Table Editor WIP: SWTBot test case: Partition Table Editor Aug 30, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (1)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (1)

47-55: Refactor the method name to follow Java naming conventions.

The method name is very long and does not follow the Java naming conventions. Please refactor it to a shorter name that follows the camelCase convention.

For example:

@Test
public void testPartitionTableEditorDisabledForNewUnbuiltProject() throws Exception {
	// ...
}
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f64ad58 and 2acabf6.

Files selected for processing (3)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (1 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (1 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (0 hunks)
Files not reviewed due to no reviewable changes (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java
Additional comments not posted (10)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (9)

35-39: LGTM!

The beforeTestClass method is correctly implemented to load the test environment.


41-45: Skipping comment as the past review feedback is still applicable.

Please address the exception handling suggestion from the previous review round.


64-69: LGTM!

The loadEnv method is correctly implemented to load the test environment.


71-75: LGTM!

The givenNewEspressifIDFProjectIsSelected method is correctly implemented to set up the project category and subcategory for the test.


77-80: LGTM!

The givenProjectNameIs method is correctly implemented to set up the project name for the test.


82-85: LGTM!

The whenNewProjectIsSelected method is correctly implemented to set up a new project for the test.


94-97: LGTM!

The whenOpenPartitionTableEditor method is correctly implemented to open the partition table editor for the test.


99-104: LGTM!

The thenEditorIsDisabled method is correctly implemented to validate the partition table editor is disabled for the test.


106-111: Skipping comment as the past review feedback is still applicable.

Please address the exception handling suggestion from the previous review round.

tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (1)

273-273: LGTM!

The change refactors the method call to use a more generic launchCommandUsingContextMenu method, which improves code reusability and maintainability. The behavior of the test case remains unchanged.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2acabf6 and c070833.

Files selected for processing (2)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (1 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range and nitpick comments (2)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (2)

581-588: LGTM! Consider adding error handling.

The checkShellContent method is well-structured and serves a clear purpose. The naming of the method and variables is appropriate and self-explanatory.

As an improvement, consider adding error handling for exceptional cases, such as when the specified shell or label is not found. This will make the method more robust and provide better feedback to the caller.


590-616: LGTM! Consider adding error handling.

The checkPartitionTableContent method is well-structured and serves a clear purpose. The naming of the method and variables is appropriate and self-explanatory.

As an improvement, consider adding error handling for exceptional cases, such as when the table is not found or has a different structure. This will make the method more robust and provide better feedback to the caller.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 622f45b and 72ca9ac.

Files selected for processing (2)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (1 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java
Additional comments not posted (1)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (1)

Line range hint 629-647: LGTM!

The joinJobByName method is well-structured and serves a clear purpose. The naming of the method and variables is appropriate and self-explanatory.

The method handles the InterruptedException by logging an error message, which is a good practice.

No changes are necessary.

Comment on lines 618 to 632
public static boolean compareRows(SWTWorkbenchBot bot) throws IOException
{
SWTBotTable table = bot.table();
int defaultRows = 3;
int actualRows = table.rowCount();
if (1 != (actualRows - defaultRows))
{
return false;
}
return true;
}
Copy link

Choose a reason for hiding this comment

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

Fix the incorrect logic.

The logic of the compareRows method seems incorrect. It checks if the actual number of rows is not equal to the default value plus one, which is the opposite of what the method name suggests.

If the actual number of rows is equal to the default value plus one, the method should return true, but it returns false instead.

Please update the logic to match the expected behavior:

public static boolean compareRows(SWTWorkbenchBot bot) throws IOException
{
    SWTBotTable table = bot.table();
    int defaultRows = 3;
    int actualRows = table.rowCount();
    return actualRows == defaultRows + 1;
}

This will ensure that the method returns true when the actual number of rows is equal to the default value plus one, and false otherwise.

@AndriiFilippov AndriiFilippov changed the title WIP: SWTBot test case: Partition Table Editor SWTBot test case: Partition Table Editor Sep 18, 2024
@AndriiFilippov
Copy link
Collaborator Author

please, review @alirana01 @sigmaaa

Tests cover basic functional checks:

  1. Project not built: Verify if a pop-up appears when opening the Partition Table.
  2. Check if the table content corresponds to the documentation.
  3. Add a row to the table.
  4. Delete a row from the table.
  5. Delete a row, Save and Quit, reopen, and verify the changes.
  6. Delete a row, Save, reopen, and verify the changes.

Copy link
Collaborator

@alirana01 alirana01 left a comment

Choose a reason for hiding this comment

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

@AndriiFilippov LGTM can you please verify the builds they are failing on linux

edit:Seems like failures are not your tests

@AndriiFilippov
Copy link
Collaborator Author

@AndriiFilippov LGTM can you please verify the builds they are failing on linux

edit:Seems like failures are not your tests

So, could merge ?

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (1)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (1)

156-161: Consider combining build operations into a single utility method

The method whenProjectIsBuiltUsingContextMenu performs multiple steps to build the project. To improve code reusability and readability, consider combining these steps into a single utility method within ProjectTestOperations.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4e33063 and d48e8b0.

📒 Files selected for processing (3)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (1 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (1 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (2 hunks)
🔇 Additional comments (7)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (2)

Line range hint 273-279: Improved code reusability with generic command launch method

The change to use ProjectTestOperations.launchCommandUsingContextMenu is a good improvement. It enhances code reusability and flexibility by using a generic method to launch context menu commands. This approach can be easily extended to other commands in the future.


Line range hint 282-284: Consistent use of generic command launch method for project refresh

This change aligns well with the previous modification, using ProjectTestOperations.launchCommandUsingContextMenu for the refresh operation. It maintains consistency in how context menu commands are executed across different operations, which is a good practice for code maintainability.

tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (3)

221-226: Exception handling in cleanTestEnv method

As previously mentioned in past review comments, the cleanTestEnv method does not handle potential exceptions. Incorporating exception handling ensures that cleanup processes are executed properly even if errors occur.


42-46: Exception handling in afterEachTest method

As previously mentioned in past review comments, the afterEachTest method calls Fixture.cleanTestEnv() without exception handling. Ensure that exceptions are caught and managed to prevent tests from failing silently.


31-34: ⚠️ Potential issue

Adjust method naming conventions in the Fixture inner class

In Java, method names should follow the camelCase convention starting with a lowercase letter. The methods within the Fixture class begin with uppercase letters (e.g., ThenInformationMessagePopUp()), which is inconsistent with Java naming conventions. Please rename these methods to improve code readability and maintainability.

Apply this diff to rename the methods:

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

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

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

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

- private static void ThenCheckChangesSaved() throws IOException
+ private static void thenCheckChangesSaved() throws IOException

Likely invalid or redundant comment.

tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (2)

27-30: LGTM on the added imports

The new imports for SWTBotLabel and SWTBotTable are appropriate for the added functionalities.


618-624: LGTM on comparePartitionTableRows method

The method comparePartitionTableRows correctly calculates the difference in row count and compares it to the expected difference.

Comment on lines +48 to +124
@Test
public void givenNewProjectCreatedNotBuiltWhenOpenPartitionTableEditorThenInformationPopUpMessage() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectPartitionTableEditor1Test");
Fixture.whenNewProjectIsSelected();
Fixture.whenOpenPartitionTableEditor();
Fixture.ThenInformationMessagePopUp();
}

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

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

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

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

@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();
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Place assertions directly within test methods for clarity

While using the Fixture class helps to organize code, placing assertions directly within the test methods enhances test clarity and makes it easier to understand the test flow. Consider refactoring the tests to include assertions in the test methods.

Comment on lines +133 to +138
private static void loadEnv() throws Exception
{
bot = WorkBenchSWTBot.getBot();
EnvSetupOperations.setupEspressifEnv(bot);
bot.sleep(1000);
}
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);
}

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

Choose a reason for hiding this comment

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

⚠️ Potential issue

Handle potential exceptions when opening the Partition Table Editor

The method whenOpenPartitionTableEditor can throw IOException, but exceptions are not being handled within the method. Consider adding exception handling to ensure that any issues are caught and logged appropriately.

Apply this diff to add exception handling:

 private static void whenOpenPartitionTableEditor()
 {
-    ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Partition Table Editor");
+    try {
+        ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Partition Table Editor");
+    } catch (IOException e) {
+        // Log the exception and handle it accordingly
+        e.printStackTrace();
+    }
 }
📝 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 whenOpenPartitionTableEditor() throws IOException
{
ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Partition Table Editor");
}
private static void whenOpenPartitionTableEditor()
{
try {
ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Partition Table Editor");
} catch (IOException e) {
// Log the exception and handle it accordingly
e.printStackTrace();
}
}

Comment on lines +626 to +632
public static void deletePartitionTableRow(SWTWorkbenchBot bot) throws IOException
{
SWTBotTable table = bot.table();
table.select(1);
bot.toolbarButton("Delete Selected").click();
bot.button("OK").click();
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add validation in deletePartitionTableRow

To prevent potential exceptions, consider adding a check to ensure that the table has at least two rows before attempting to select and delete a row at index 1.

Apply this diff to add validation:

 public static void deletePartitionTableRow(SWTWorkbenchBot bot) throws IOException
 {
     SWTBotTable table = bot.table();
+    if (table.rowCount() > 1) {
         table.select(1);
         bot.toolbarButton("Delete Selected").click();
         bot.button("OK").click();
+    } else {
+        // Handle the case where there are not enough rows to delete
+        throw new IllegalStateException("Unable to delete row: Table does not have enough rows.");
+    }
 }
📝 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
public static void deletePartitionTableRow(SWTWorkbenchBot bot) throws IOException
{
SWTBotTable table = bot.table();
table.select(1);
bot.toolbarButton("Delete Selected").click();
bot.button("OK").click();
}
public static void deletePartitionTableRow(SWTWorkbenchBot bot) throws IOException
{
SWTBotTable table = bot.table();
if (table.rowCount() > 1) {
table.select(1);
bot.toolbarButton("Delete Selected").click();
bot.button("OK").click();
} else {
// Handle the case where there are not enough rows to delete
throw new IllegalStateException("Unable to delete row: Table does not have enough rows.");
}
}

Comment on lines +581 to +588
public static boolean checkShellContent(SWTWorkbenchBot bot, String shellName, String expectedText)
{
SWTBotShell shell = bot.shell(shellName);
shell.activate();
SWTBotLabel label = bot.label(expectedText);
String actualText = label.getText();
return expectedText.equals(actualText);
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Handle potential exceptions in checkShellContent

The method checkShellContent may throw a WidgetNotFoundException if the shell or label with the expected text is not found. To enhance robustness, consider catching this exception and returning false when the shell or label is not found.

Apply this diff to handle exceptions:

 public static boolean checkShellContent(SWTWorkbenchBot bot, String shellName, String expectedText)
 {
     try {
         SWTBotShell shell = bot.shell(shellName);
         shell.activate();
         SWTBotLabel label = bot.label(expectedText);
         String actualText = label.getText();
         return expectedText.equals(actualText);
     } catch (WidgetNotFoundException e) {
         return false;
     }
 }
📝 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
public static boolean checkShellContent(SWTWorkbenchBot bot, String shellName, String expectedText)
{
SWTBotShell shell = bot.shell(shellName);
shell.activate();
SWTBotLabel label = bot.label(expectedText);
String actualText = label.getText();
return expectedText.equals(actualText);
}
public static boolean checkShellContent(SWTWorkbenchBot bot, String shellName, String expectedText)
{
try {
SWTBotShell shell = bot.shell(shellName);
shell.activate();
SWTBotLabel label = bot.label(expectedText);
String actualText = label.getText();
return expectedText.equals(actualText);
} catch (WidgetNotFoundException e) {
return false;
}
}

Comment on lines +590 to +616
public static boolean checkPartitionTableContent(SWTWorkbenchBot bot)
{
String[] builtInPartitionArray = { "nvs", "phy_init", "factory", "data", "data", "app", "nvs", "phy", "factory",
"0x9000", "0xf000", "0x10000", "0x6000", "0x1000", "1M", "", "", "" };
int builtInIndex = 0;
SWTBotTable table = bot.table();
int columns = table.columnCount();
int rows = table.rowCount();
if (columns != 6 && rows != 3)
{
return false;
}
for (int col = 0; col < columns; col++)
{
for (int row = 0; row < rows; row++)
{
String tableContent = table.cell(row, col);

if (!builtInPartitionArray[builtInIndex].equals(tableContent))
{
return false;
}
builtInIndex++;
}
}
return true;
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Correct the condition and loop order in checkPartitionTableContent

  1. Incorrect logical operator in the condition

    The condition if (columns != 6 && rows != 3) should use the logical OR operator || to correctly validate the table dimensions. Using && means the return false statement will not execute if either columns equals 6 or rows equals 3.

  2. Swap the loop order for proper traversal

    The nested loops should iterate over rows first and then columns to access table cells in row-major order, matching the structure of builtInPartitionArray.

Apply this diff to correct the issues:

 public static boolean checkPartitionTableContent(SWTWorkbenchBot bot)
 {
     String[] builtInPartitionArray = { "nvs", "phy_init", "factory", "data", "data", "app", "nvs", "phy", "factory",
             "0x9000", "0xf000", "0x10000", "0x6000", "0x1000", "1M", "", "", "" };
     int builtInIndex = 0;
     SWTBotTable table = bot.table();
     int columns = table.columnCount();
     int rows = table.rowCount();
-    if (columns != 6 && rows != 3)
+    if (columns != 6 || rows != 3)
     {
         return false;
     }
-    for (int col = 0; col < columns; col++)
+    for (int row = 0; row < rows; row++)
     {
-        for (int row = 0; row < rows; row++)
+        for (int col = 0; col < columns; col++)
         {
             String tableContent = table.cell(row, col);

             if (!builtInPartitionArray[builtInIndex].equals(tableContent))
             {
                 return false;
             }
             builtInIndex++;
         }
     }
     return true;
 }
📝 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
public static boolean checkPartitionTableContent(SWTWorkbenchBot bot)
{
String[] builtInPartitionArray = { "nvs", "phy_init", "factory", "data", "data", "app", "nvs", "phy", "factory",
"0x9000", "0xf000", "0x10000", "0x6000", "0x1000", "1M", "", "", "" };
int builtInIndex = 0;
SWTBotTable table = bot.table();
int columns = table.columnCount();
int rows = table.rowCount();
if (columns != 6 && rows != 3)
{
return false;
}
for (int col = 0; col < columns; col++)
{
for (int row = 0; row < rows; row++)
{
String tableContent = table.cell(row, col);
if (!builtInPartitionArray[builtInIndex].equals(tableContent))
{
return false;
}
builtInIndex++;
}
}
return true;
}
public static boolean checkPartitionTableContent(SWTWorkbenchBot bot)
{
String[] builtInPartitionArray = { "nvs", "phy_init", "factory", "data", "data", "app", "nvs", "phy", "factory",
"0x9000", "0xf000", "0x10000", "0x6000", "0x1000", "1M", "", "", "" };
int builtInIndex = 0;
SWTBotTable table = bot.table();
int columns = table.columnCount();
int rows = table.rowCount();
if (columns != 6 || rows != 3)
{
return false;
}
for (int row = 0; row < rows; row++)
{
for (int col = 0; col < columns; col++)
{
String tableContent = table.cell(row, col);
if (!builtInPartitionArray[builtInIndex].equals(tableContent))
{
return false;
}
builtInIndex++;
}
}
return true;
}

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d48e8b0 and d392805.

📒 Files selected for processing (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectSBOMTest.java (1 hunks)
🧰 Additional context used

Comment on lines 76 to 91
// @Test
// public void givenNewProjectCreatedBuiltWhenRunSBOMtoolRedirectOutputToFileThenCheckConsoleAndSbomFile()
// throws Exception
// {
// Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
// Fixture.givenProjectNameIs("NewProjectSbomThirdTest");
// Fixture.whenNewProjectIsSelected();
// Fixture.whenProjectIsBuiltUsingContextMenu();
// Fixture.whenOpenSbomTool();
// Fixture.whenRedirectOutputToTheFileClicked();
// Fixture.whenRunSbomTool();
// Fixture.thenCheckInConsole();
// Fixture.whenRefreshProject();
// Fixture.thenOpenSbomFile();
// Fixture.thenCheckSbomFile();
// }
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

SBOM tool output redirection lacks active tests.

The test method givenNewProjectCreatedBuiltWhenRunSBOMtoolRedirectOutputToFileThenCheckConsoleAndSbomFile has been commented out, and no other tests currently cover the functionality of redirecting SBOM tool output to a file. This may lead to unverified behavior in the SBOM feature.

Please address this by either re-enabling the commented-out test or adding new tests to ensure comprehensive coverage of the SBOM tool's output redirection functionality.

🔗 Analysis chain

Clarify the reason for commenting out the test method.

The test method givenNewProjectCreatedBuiltWhenRunSBOMtoolRedirectOutputToFileThenCheckConsoleAndSbomFile has been commented out. This test appears to cover a specific scenario of redirecting SBOM tool output to a file and verifying the results, which seems important for ensuring the tool's functionality.

Could you please clarify:

  1. Why was this test method commented out?
  2. Is the functionality it tests still relevant?
  3. If so, is this scenario covered by other tests, or should we consider re-enabling this test?

Ensuring comprehensive test coverage is crucial for maintaining the reliability of the SBOM tool feature.

To help verify the current test coverage, you can run the following script:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for tests related to SBOM file output redirection

# Test: Look for other test methods that might cover similar functionality
rg --type java -i "redirect.*output.*file" tests/

Length of output: 1348

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (2)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (2)

Line range hint 389-395: Approve refactoring of component installation method

The change from openProjectNewComponentUsingContextMenu to launchCommandUsingContextMenu appears to be a good refactoring that improves code reusability. This change is approved.

However, consider extracting the string "Install New Component" into a constant to improve maintainability and reduce the risk of typos.

Consider applying this change:

+ private static final String INSTALL_NEW_COMPONENT_COMMAND = "Install New Component";

- ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Install New Component");
+ ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, INSTALL_NEW_COMPONENT_COMMAND);

Line range hint 183-395: Overall feedback: Remove duplicates and focus on meaningful test additions

The changes in this file primarily consist of adding duplicate test methods, which is not a recommended practice in test development. Here are some suggestions for improvement:

  1. Remove all duplicate test methods (those with suffix '1').
  2. If the intention is to increase test coverage, consider adding new test cases that cover different scenarios, edge cases, or potential failure modes.
  3. Instead of duplicating entire methods, you could parameterize existing tests to cover multiple scenarios.
  4. The refactoring in the whenInstallNewComponentUsingContextMenu method is a good change. Consider applying similar refactoring to other methods if applicable.

By focusing on meaningful test additions and avoiding duplication, you can improve the overall quality and maintainability of the test suite.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 577f794 and acf724e.

📒 Files selected for processing (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java (2 hunks)
🧰 Additional context used

Comment on lines 183 to 191
@Test
public void givenNewIDFProjectIsSelectedThenProjectIsCreatedAndAddedToProjectExplorer1() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectTest");
Fixture.whenNewProjectIsSelected();
Fixture.thenProjectIsAddedToProjectExplorer();

}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove duplicate test method

This test method is an exact duplicate of givenNewIDFProjectIsSelectedThenProjectIsCreatedAndAddedToProjectExplorer. Duplicate tests don't add value to the test suite and increase maintenance overhead. Consider removing this method or modifying it to test a different scenario if needed.

Comment on lines 193 to 297
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");
}

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

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

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

@Test
public void givenNewProjectCreatedDfuBuiltThenHasDfuBin1() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectTestDFU");
Fixture.whenNewProjectIsSelected();
Fixture.thenLaunchTargetIsSelectedFromLaunchTargets("esp32s2");
Fixture.turnOnDfu();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.thenProjectHasTheFile("dfu.bin", "/build");
Fixture.turnOffDfu();
}

@Test
public void givenNewProjectCreatedThenInstallNewComponent1() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectForInstallNewComponentTest");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.whenInstallNewComponentUsingContextMenu();
Fixture.whenRefreshProject();
Fixture.checkIfNewComponentIsInstalledUsingContextMenu();
}

@Test
public void givenNewProjectCreatedBuiltAndThenProjectCleanUsingContextMenu1() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectCleanTest");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.whenProjectCleanUsingContextMenu();
Fixture.whenRefreshProject();
Fixture.checkIfProjectCleanedFilesInBuildFolder();
}

@Test
public void givenNewProjectCreatedBuiltAndThenProjectFullCleanUsingContextMenu1() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectFullCleanTest");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.whenProjectFullCleanUsingContextMenu();
Fixture.whenRefreshProject();
Fixture.checkIfProjectFullCleanedFilesInBuildFolder();
}

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

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove all duplicate test methods

All test methods with the suffix '1' (from lines 193 to 297) are exact duplicates of existing test methods. This includes:

  • givenNewIDFProjectIsSelectedFromTemplateThenProjectIsCreatedAndAddedToProjectExplorerWithRequiredFiles1
  • givenNewIDFProjectIsCreatedAndBuiltUsingContextMenuOnProjectThenProjectIsCreatedAndBuilt1
  • givenNewIDFProjectIsCreatedAndBuiltUsingToolbarButtonThenProjectIsBuilt1
  • givenNewProjectCreatedAndRenamedAfterThenProjectIsBuildSuccessfully1
  • givenNewProjectCreatedDfuBuiltThenHasDfuBin1
  • givenNewProjectCreatedThenInstallNewComponent1
  • givenNewProjectCreatedBuiltAndThenProjectCleanUsingContextMenu1
  • givenNewProjectCreatedBuiltAndThenProjectFullCleanUsingContextMenu1
  • givenNewProjectCreatedBuiltAndThenProjectPythonCleanUsingContextMenu1

Duplicating test methods without changes doesn't improve test coverage and increases maintenance overhead. Consider removing these duplicate methods. If the intention is to test different scenarios or edge cases, modify the methods to reflect those specific cases instead of creating exact duplicates.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (6)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/EnvSetupOperations.java (1)

80-81: LGTM! Consider adding a clarifying comment.

The cleanup of the ESP-IDF Manager tab is a good practice for test isolation. Consider adding a comment to explain the purpose:

+  // Cleanup: Ensure ESP-IDF Manager tab is closed after setup to prevent UI state interference
   bot.cTabItem("ESP-IDF Manager").activate();
   bot.cTabItem("ESP-IDF Manager").close();
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (3)

25-30: Update class header documentation

The class header comment incorrectly states this is for testing the "SBOM feature". Please update it to reflect that this class tests the Partition Table Editor functionality.

 /**
- * Test class to test the SBOM feature
+ * Test class to test the Partition Table Editor functionality
  *
  * @author Andrii Filippov
  *
  */

55-131: Consider more concise test method names and specific exceptions

While the test methods are well-structured, consider:

  1. Using shorter but still descriptive names
  2. Declaring specific exceptions instead of the broad Exception

Example of more concise naming:

-public void givenNewProjectCreatedNotBuiltWhenOpenPartitionTableEditorThenInformationPopUpMessage()
+public void openEditorWithoutBuildShowsInfoMessage()

-public void givenNewProjectCreatedBuiltWhenOpenPartitionTableEditorThenBuiltInPartitionTableDisplayed()
+public void openEditorWithBuiltProjectShowsTable()

Example of specific exception handling:

-public void openEditorWithoutBuildShowsInfoMessage() throws Exception
+public void openEditorWithoutBuildShowsInfoMessage() throws IOException

34-35: Consider adding edge case tests

The current test suite covers basic functionality well. Consider adding tests for:

  1. Invalid partition table configurations
  2. Maximum/minimum values for partition sizes
  3. Concurrent access to the partition table
  4. Error scenarios during save operations

Would you like assistance in implementing these additional test cases?

tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (2)

88-89: Consider making the build wait timeout configurable

The build wait timeout has been reduced from 600,000ms to 300,000ms. While this might be sufficient for most cases, consider making it configurable through a system property to handle varying build times across different environments.

The addition of consoleView.close() is good as it helps clean up UI resources.

- DefaultPropertyFetcher.getLongPropertyValue(DEFAULT_PROJECT_BUILD_WAIT_PROPERTY, 300000));
+ DefaultPropertyFetcher.getLongPropertyValue(DEFAULT_PROJECT_BUILD_WAIT_PROPERTY, 
+    System.getProperty("build.wait.timeout", "300000")));

621-627: Improve readability of comparePartitionTableRows

The method could be more readable by using descriptive variable names and extracting the calculation into a separate variable.

 public static boolean comparePartitionTableRows(SWTWorkbenchBot bot, int expectedDifference) throws IOException
 {
     SWTBotTable table = bot.table();
-    int defaultRows = 3;
+    int expectedBaseRows = 3;
     int actualRows = table.rowCount();
-    return (actualRows - defaultRows) == expectedDifference;
+    int actualDifference = actualRows - expectedBaseRows;
+    return actualDifference == expectedDifference;
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between acf724e and c009d36.

📒 Files selected for processing (3)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (1 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/EnvSetupOperations.java (1 hunks)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (4 hunks)
🔇 Additional comments (6)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectPartitionTableEditorTest.java (3)

36-53: LGTM! Good error handling in setup/teardown

The setup and teardown methods are well-implemented with proper error handling.


140-145: Replace fixed delay with explicit wait condition

The bot.sleep(1000) should be replaced with an explicit wait condition as suggested in the previous review.


170-173: Add exception handling in whenOpenPartitionTableEditor

The method should handle potential exceptions as suggested in the previous review.

tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (3)

584-591: Add error handling in checkShellContent

This is a duplicate of a previous review comment. The method needs to handle WidgetNotFoundException when the shell or label is not found.


593-619: Fix logical operator and loop order in checkPartitionTableContent

This is a duplicate of a previous review comment. The method needs:

  1. Correct logical operator in the dimension check
  2. Swap the loop order for proper traversal

629-635: Add validation in deletePartitionTableRow

This is a duplicate of a previous review comment. The method needs to validate that the table has enough rows before attempting to delete.

Comment on lines +175 to +179
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."));
}
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

Comment on lines 304 to 305
bot.cTabItem("README.md").activate();
bot.cTabItem("README.md").close();
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 handling potential widget exceptions

The README tab operations might fail if the tab doesn't exist. Consider adding error handling.

- bot.cTabItem("README.md").activate();
- bot.cTabItem("README.md").close();
+ try {
+     SWTBotCTabItem readmeTab = bot.cTabItem("README.md");
+     readmeTab.activate();
+     readmeTab.close();
+ } catch (WidgetNotFoundException e) {
+     logger.debug("README.md tab not found", e);
+ }

Committable suggestion skipped: line range outside the PR's diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants