-
Notifications
You must be signed in to change notification settings - Fork 120
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
base: master
Are you sure you want to change the base?
Conversation
WalkthroughThe new file Changes
Suggested reviewers
PoemThrough tests we march with great delight, Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Files skipped from review as they are similar to previous changes (1)
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
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 genericException
. 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 upOR
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.
public void afterEachTest() | ||
{ | ||
Fixture.cleanTestEnv(); | ||
} |
There was a problem hiding this comment.
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();
}
}
private static void cleanTestEnv() | ||
{ | ||
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot); | ||
ProjectTestOperations.closeAllProjects(bot); | ||
ProjectTestOperations.deleteAllProjects(bot); | ||
} |
There was a problem hiding this comment.
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();
}
}
@alirana01 please review this |
f64ad58
to
2acabf6
Compare
There was a problem hiding this 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
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.
There was a problem hiding this 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
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
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); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Consider a minor refactoring.
The new checkShellContent
method seems to be a useful addition for UI testing. The implementation logic is straightforward and easy to understand.
As a minor improvement, consider extracting the label text comparison logic to a separate private method, something like:
private static boolean isLabelTextMatching(SWTBotLabel label, String expectedText) {
return expectedText.equals(label.getText());
}
And then use it in checkShellContent
:
return isLabelTextMatching(label, expectedText);
This would improve readability and reusability of the text comparison logic.
There was a problem hiding this 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
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.
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; | ||
} |
There was a problem hiding this comment.
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.
please, review @alirana01 @sigmaaa Tests cover basic functional checks:
|
Description
add Partition Table Editor test cases.
Type of change
Checklist
Summary by CodeRabbit