void () { final Ref<Integer> count = Ref.create(0); myTaskManager.addTaskListener(new TaskListenerAdapter() { @Override public void taskActivated(@NotNull LocalTask task) { count.set(count.get() + 1); } }, getTestRootDisposable()); myTaskManager.activateTask(myTaskManager.createLocalTask("foo"), false); assertEquals(1, count.get().intValue()); myTaskManager.activateTask(myTaskManager.createLocalTask("bar"), false); assertEquals(2, count.get().intValue()); }