@Test public void itIsIllegalToMoveToSetupWhenAlreadyInExecutableContext_insideTestCase() throws Exception { final RobotFile model = ModelBuilder.modelForFile() .withTestCasesTable() .withTestCase("test") .executable("log", "10") .executable("log", "20") .build(); final List<RobotExecutableRow<TestCase>> rows = model.getTestCaseTable() .getTestCases() .get(0) .getExecutionContext(); final List<ExecutableWithDescriptor> executables = ExecutablesCompiler.compileExecutables(rows, null); final RobotBreakpointSupplier bpSupplier = mock(RobotBreakpointSupplier.class); final ExecutableCallContext context = new ExecutableCallContext(newArrayList(), executables, 0, URI.create("file: assertThatExceptionOfType(IllegalDebugContextStateException.class) .isThrownBy(() -> context.moveTo(new RunningKeyword("lib", "kw", KeywordCallType.SETUP), bpSupplier)) .withMessage( "Setup keyword cannot be called when already executing keywords inside test case or other keyword") .withNoCause(); }
@Override public StackFrameContext moveTo(final RunningKeyword runningKeyword, final RobotBreakpointSupplier breakpointSupplier) { final RobotExecutableRow<?> executable = elements.get(index).getExecutable(); if (runningKeyword.isTeardown() && executable.getModelType() == ModelType.TEST_CASE_EXECUTABLE_ROW) { final TestCase testCase = (TestCase) executable.getParent(); return CommonContextsTransitions.moveToTestSetupOrTeardown(testCase, models, runningKeyword, this, breakpointSupplier); } else if (runningKeyword.isTeardown() && executable.getModelType() == ModelType.USER_KEYWORD_EXECUTABLE_ROW) { final UserKeyword keyword = (UserKeyword) executable.getParent(); return moveToKeywordTeardown(keyword, runningKeyword, breakpointSupplier); } else if (runningKeyword.isSetup()) { throw new IllegalDebugContextStateException( "Setup keyword cannot be called when already executing keywords inside test case or other keyword"); } else { return CommonContextsTransitions.moveToExecutable(models, locationUri, elements, index + 1, runningKeyword, breakpointSupplier); } }
ExecutableCallContext extends DefaultContext { @Override public StackFrameContext moveTo(final RunningKeyword runningKeyword, final RobotBreakpointSupplier breakpointSupplier) { final RobotExecutableRow<?> executable = elements.get(index).getExecutable(); if (runningKeyword.isTeardown() && executable.getModelType() == ModelType.TEST_CASE_EXECUTABLE_ROW) { final TestCase testCase = (TestCase) executable.getParent(); return CommonContextsTransitions.moveToTestSetupOrTeardown(testCase, models, runningKeyword, this, breakpointSupplier); } else if (runningKeyword.isTeardown() && executable.getModelType() == ModelType.USER_KEYWORD_EXECUTABLE_ROW) { final UserKeyword keyword = (UserKeyword) executable.getParent(); return moveToKeywordTeardown(keyword, runningKeyword, breakpointSupplier); } else if (runningKeyword.isSetup()) { throw new IllegalDebugContextStateException( "Setup keyword cannot be called when already executing keywords inside test case or other keyword"); } else { return CommonContextsTransitions.moveToExecutable(models, locationUri, elements, index + 1, runningKeyword, breakpointSupplier); } } }
ExecutableCallContext extends DefaultContext { @Override public StackFrameContext moveTo(final RunningKeyword runningKeyword, final RobotBreakpointSupplier breakpointSupplier) { final RobotExecutableRow<?> executable = elements.get(index).getExecutable(); if (runningKeyword.isTeardown() && executable.getModelType() == ModelType.TEST_CASE_EXECUTABLE_ROW) { final TestCase testCase = (TestCase) executable.getParent(); return CommonContextsTransitions.moveToTestSetupOrTeardown(testCase, models, runningKeyword, this, breakpointSupplier); } else if (runningKeyword.isTeardown() && executable.getModelType() == ModelType.USER_KEYWORD_EXECUTABLE_ROW) { final UserKeyword keyword = (UserKeyword) executable.getParent(); return moveToKeywordTeardown(keyword, runningKeyword, breakpointSupplier); } else if (runningKeyword.isSetup()) { throw new IllegalDebugContextStateException( "Setup keyword cannot be called when already executing keywords inside test case or other keyword"); } else { return CommonContextsTransitions.moveToExecutable(models, locationUri, elements, index + 1, runningKeyword, breakpointSupplier); } } ExecutableCallContext(final List<RobotFile> models, final List<ExecutableWithDescriptor> elements, final int index,
            final URI locationUri, final int line, final RobotBreakpointSupplier breakpointSupplier);   ExecutableCallContext(final List<RobotFile> models, final List<ExecutableWithDescriptor> elements, final int index,
            final URI locationUri, final int line, final String errorMessage,
            final RobotBreakpointSupplier breakpointSupplier); }
ExecutableCallContext extends DefaultContext { @Override public StackFrameContext moveTo(final RunningKeyword runningKeyword, final RobotBreakpointSupplier breakpointSupplier) { final RobotExecutableRow<?> executable = elements.get(index).getExecutable(); if (runningKeyword.isTeardown() && executable.getModelType() == ModelType.TEST_CASE_EXECUTABLE_ROW) { final TestCase testCase = (TestCase) executable.getParent(); return CommonContextsTransitions.moveToTestSetupOrTeardown(testCase, models, runningKeyword, this, breakpointSupplier); } else if (runningKeyword.isTeardown() && executable.getModelType() == ModelType.USER_KEYWORD_EXECUTABLE_ROW) { final UserKeyword keyword = (UserKeyword) executable.getParent(); return moveToKeywordTeardown(keyword, runningKeyword, breakpointSupplier); } else if (runningKeyword.isSetup()) { throw new IllegalDebugContextStateException( "Setup keyword cannot be called when already executing keywords inside test case or other keyword"); } else { return CommonContextsTransitions.moveToExecutable(models, locationUri, elements, index + 1, runningKeyword, breakpointSupplier); } } ExecutableCallContext(final List<RobotFile> models, final List<ExecutableWithDescriptor> elements, final int index,
            final URI locationUri, final int line, final RobotBreakpointSupplier breakpointSupplier);   ExecutableCallContext(final List<RobotFile> models, final List<ExecutableWithDescriptor> elements, final int index,
            final URI locationUri, final int line, final String errorMessage,
            final RobotBreakpointSupplier breakpointSupplier); @Override boolean isErroneous(); @Override Optional<String> getErrorMessage(); @Override Optional<URI> getAssociatedPath(); @Override Optional<FileRegion> getFileRegion(); boolean isOnLastExecutable(); @Override StackFrameContext moveTo(final RunningKeyword runningKeyword,
            final RobotBreakpointSupplier breakpointSupplier); @Override Optional<RobotBreakpoint> getLineBreakpoint(); @Override Optional<RobotBreakpoint> getKeywordFailBreakpoint(final QualifiedKeywordName currentlyFailedKeyword); }
ExecutableCallContext extends DefaultContext { @Override public StackFrameContext moveTo(final RunningKeyword runningKeyword, final RobotBreakpointSupplier breakpointSupplier) { final RobotExecutableRow<?> executable = elements.get(index).getExecutable(); if (runningKeyword.isTeardown() && executable.getModelType() == ModelType.TEST_CASE_EXECUTABLE_ROW) { final TestCase testCase = (TestCase) executable.getParent(); return CommonContextsTransitions.moveToTestSetupOrTeardown(testCase, models, runningKeyword, this, breakpointSupplier); } else if (runningKeyword.isTeardown() && executable.getModelType() == ModelType.USER_KEYWORD_EXECUTABLE_ROW) { final UserKeyword keyword = (UserKeyword) executable.getParent(); return moveToKeywordTeardown(keyword, runningKeyword, breakpointSupplier); } else if (runningKeyword.isSetup()) { throw new IllegalDebugContextStateException( "Setup keyword cannot be called when already executing keywords inside test case or other keyword"); } else { return CommonContextsTransitions.moveToExecutable(models, locationUri, elements, index + 1, runningKeyword, breakpointSupplier); } } ExecutableCallContext(final List<RobotFile> models, final List<ExecutableWithDescriptor> elements, final int index,
            final URI locationUri, final int line, final RobotBreakpointSupplier breakpointSupplier);   ExecutableCallContext(final List<RobotFile> models, final List<ExecutableWithDescriptor> elements, final int index,
            final URI locationUri, final int line, final String errorMessage,
            final RobotBreakpointSupplier breakpointSupplier); @Override boolean isErroneous(); @Override Optional<String> getErrorMessage(); @Override Optional<URI> getAssociatedPath(); @Override Optional<FileRegion> getFileRegion(); boolean isOnLastExecutable(); @Override StackFrameContext moveTo(final RunningKeyword runningKeyword,
            final RobotBreakpointSupplier breakpointSupplier); @Override Optional<RobotBreakpoint> getLineBreakpoint(); @Override Optional<RobotBreakpoint> getKeywordFailBreakpoint(final QualifiedKeywordName currentlyFailedKeyword);  }