From teikk-agents-skills
Implements unit testing and performance benchmarking in Java. Use when writing Java JUnit tests, Mockito unit/integration tests, Espresso UI tests, or Macrobenchmark configurations.
How this skill is triggered — by the user, by Claude, or both
Slash command
/teikk-agents-skills:android-testing-and-benchmark-javaThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Perform unit testing, XML-based UI testing, and performance benchmarking on Java Android projects. Ensure correct execution boundaries and regression protection.
Perform unit testing, XML-based UI testing, and performance benchmarking on Java Android projects. Ensure correct execution boundaries and regression protection.
android-testing-and-benchmark-kotlin instead).Mockito.mock()) to isolate dependencies.public class TaskViewModelTest {
@Rule
public InstantTaskExecutorRule instantTaskExecutorRule = new InstantTaskExecutorRule();
private GetTasksUseCase getTasksUseCase;
private TaskViewModel viewModel;
@Before
public void setUp() {
// Mock dependencies
getTasksUseCase = Mockito.mock(GetTasksUseCase.class);
// Force RxJava to execute synchronously in tests
RxAndroidPlugins.setInitMainThreadSchedulerHandler(scheduler -> Schedulers.trampoline());
RxJavaPlugins.setIoSchedulerHandler(scheduler -> Schedulers.trampoline());
// Setup mock response
List<Task> tasks = Collections.singletonList(new Task("1", "Java Task", false));
Mockito.when(getTasksUseCase.execute()).thenReturn(Single.just(tasks));
}
@Test
public void loadTasks_Success_UpdatesLiveData() {
viewModel = new TaskViewModel(getTasksUseCase);
viewModel.loadTasks();
assertNotNull(viewModel.getUiState().getValue());
assertEquals(1, viewModel.getUiState().getValue().getTasks().size());
assertEquals("Java Task", viewModel.getUiState().getValue().getTasks().get(0).getTitle());
}
@After
public void tearDown() {
RxAndroidPlugins.reset();
RxJavaPlugins.reset();
}
}
@RunWith(AndroidJUnit4.class)
@LargeTest
public class TaskListActivityTest {
@Rule
public ActivityScenarioRule<TaskListActivity> activityRule =
new ActivityScenarioRule<>(TaskListActivity.class);
@Test
public void taskListScreen_displayHeader() {
// Verify view is displayed and contains correct title
onView(withId(R.id.recyclerView)).check(matches(isDisplayed()));
onView(withText("Java Tasks")).check(matches(isDisplayed()));
}
}
@RunWith(AndroidJUnit4.class)
@LargeTest
public class StartupBenchmark {
@Rule
public MacrobenchmarkRule benchmarkRule = new MacrobenchmarkRule();
@Test
public void startupCold() {
benchmarkRule.measureRepeated(
"com.example.tasks.java",
Collections.singletonList(new StartupTimingMetric()),
CompilationMode.DEFAULT,
5,
setupBlock -> {
// Perform actions before startup (like pressing home)
return null;
},
measureBlock -> {
// Launch app under test
return null;
}
);
}
}
| Rationalization | Reality |
|---|---|
| "Mockito mocks are enough, I don't need real device tests" | Mockito mocks can hide integration bugs. You need Espresso to verify that clicks trigger layouts and that XML files load without inflation crashes. |
| "I'll test my RxJava flows using standard async calls in JUnit" | Java unit tests exit immediately before background threads (like Schedulers.io()) finish. You must override Schedulers to Schedulers.trampoline() or use TestObserver. |
| "Writing Espresso tests takes too long because of UI updates" | Espresso handles synchronization with UI events automatically. Using it prevents regressions in critical user flows. |
Thread.sleep calls to wait for views (causes flakiness; use IdlingResources instead).InstantTaskExecutorRule rule when testing LiveData inside ViewModels (causes "Method getMainLooper not mocked" error).RxJavaPlugins.reset() after completing tests that modified schedulers (causes cross-test contamination).Bundle, Intent, Context) instead of using mock contexts or instrumentation../gradlew test.InstantTaskExecutorRule context.Provides behavioral guidelines to reduce common LLM coding mistakes, focusing on simplicity, surgical changes, assumption surfacing, and verifiable success criteria.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub 22teikk/22teikk-agent-skills-hub --plugin teikk-agents-skills