### Question:
CacheHandlingServiceImpl extends AbstractTeardownService implements TeardownService { protected void writeCachedStepDefinitions(TestSuite testSuite) { try { TestCaseStepHelper.writeCachedStepDefinitions(testSuite); } catch (IOException e) { throw new SakuliRuntimeException("Can't create cache file(s) for test case steps!", e); } }  @Override int getServicePriority(); @Override void teardownTestSuite(@NonNull TestSuite testSuite);  }### Answer:
@Test public void testWriteCachedStepDefinitions() throws Exception { final String cacheFilePath = "valid/validTestCase/" + TestCaseStepHelper.STEPS_CACHE_FILE; if (this.getClass().getResource(cacheFilePath) != null) { Files.deleteIfExists(getResource(cacheFilePath, true)); } Path tcFile = getResource("valid/validTestCase/_tc.js", true); testSuite.setState(TestSuiteState.ERRORS); TestCase tc = new TestCase("test", "test"); tc.setTcFile(tcFile); tc.setSteps(Arrays.asList( new TestCaseStepBuilder("step_ok").withState(TestCaseStepState.OK).build(), new TestCaseStepBuilder("step_not_started").build(), new TestCaseStepBuilder("step_warning").withState(TestCaseStepState.WARNING).build() )); testSuite.setTestCases(Collections.singletonMap("1", tc)); testling.tearDown(Optional.of(testSuite)); assertNull(getResource(cacheFilePath, false)); testSuite.setState(TestSuiteState.CRITICAL_IN_SUITE); testling.tearDown(Optional.of(testSuite)); Path cacheFile = getResource(cacheFilePath, true); assertTrue(Files.exists(cacheFile)); assertEquals(FileUtils.readFileToString(cacheFile.toFile(), Charset.forName("UTF-8")), "step_ok\nstep_warning\n"); }