用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ForceInjection/domain-driven-design-skills --skill karibu-tester命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | karibu-tester |
| description | Creates Karibu unit tests for Vaadin views. |
Create Karibu unit tests for Vaadin views. Karibu Testing allows server-side testing of Vaadin components without a browser.
Use the KaribuTesting MCP server for documentation and code generation.
Create test data using Flyway migrations in src/test/resources/db/migration.
| Approach | Location | Purpose |
|---|---|---|
| Flyway migration | src/test/resources/db/migration/V*.sql | Populate test data |
| Manual cleanup | @AfterEach method | Remove test-created data |
| Class | Purpose |
|---|---|
| com.github.mvysny.kaributesting.v10.LocatorJ | Find components |
| com.github.mvysny.kaributesting.v10.GridKt | Grid assertions and interactions |
| com.github.mvysny.kaributesting.v10.NotificationsKt | Notification assertions |
| com.github.mvysny.kaributesting.v10.pro.ConfirmDialogKt | ConfirmDialog interactions |
Use templates/ExampleViewTest.java as the test class structure.
UI.getCurrent().
navigate(PersonView .class);
// Find by type
var grid = _get(Grid.class);
var button = _get(Button.class, spec -> spec.withCaption("Save"));
var textField = _get(TextField.class, spec -> spec.withLabel("Name"));
// Find all matching
List<Button> buttons = _find(Button.class);
// Get grid size
assertThat(GridKt._size(grid)).
isEqualTo(100);
// Get selected items
Set<PersonRecord> selected = grid.getSelectedItems();
// Select a row
GridKt.
_selectRow(grid, 0);
// Get cell component (for action buttons)
GridKt.
_getCellComponent(grid, 0,"actions")
.
getChildren()
.
filter(Button .class::isInstance)
.
findFirst()
.
map(Button .class::cast)
.
ifPresent(Button::click);
// Get cell value
String name = GridKt._getFormattedRow(grid, 0).get("name");
// Set field values
_get(TextField .class, spec ->spec.
withLabel("Name")).
_setValue("John");
_get(ComboBox .class, spec ->spec.
withLabel("Country")).
_setValue(country);
_get(DatePicker .class, spec ->spec.
withLabel("Birth Date")).
_setValue(LocalDate.of(1990, 1,1));
// Click button
_get(Button .class, spec ->spec.
withCaption("Save")).
_click();
// Expect notification
expectNotifications("Record saved successfully");
// Assert no notifications
assertThat(NotificationsKt.getNotifications()).
isEmpty();
// Click confirm in dialog
ConfirmDialogKt._fireConfirm(_get(ConfirmDialog.class));
// Click cancel
ConfirmDialogKt.
_fireCancel(_get(ConfirmDialog.class));
Use AssertJ or Karibu Testing assertions:
| Assertion Type | Example |
|---|---|
| Grid size | assertThat(GridKt._size(grid)).isEqualTo(10) |
| Component visible | assertThat(button.isVisible()).isTrue() |
| Component enabled | assertThat(button.isEnabled()).isTrue() |
| Field value | assertThat(textField.getValue()).isEqualTo("x") |
| Collection size | assertThat(items).hasSize(5) |
| Notifications | expectNotifications("Success") |