Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion com.avaloq.tools.ddk.test.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: com.avaloq.tools.ddk.test.core
Bundle-SymbolicName: com.avaloq.tools.ddk.test.core;singleton:=true
Bundle-Version: 18.0.1.qualifier
Bundle-Version: 18.0.2.qualifier
Bundle-Vendor: Avaloq Group AG
Bundle-RequiredExecutionEnvironment: JavaSE-21
Bundle-ActivationPolicy: lazy
Expand Down
2 changes: 1 addition & 1 deletion com.avaloq.tools.ddk.test.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<version>18.0.1-SNAPSHOT</version>
<relativePath>../ddk-parent</relativePath>
</parent>
<version>18.0.1-SNAPSHOT</version>
<version>18.0.2-SNAPSHOT</version>

<artifactId>com.avaloq.tools.ddk.test.core</artifactId>
<packaging>eclipse-plugin</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void interceptTestMethod(final Invocation<Void> invocation, final Reflect
if (issueAnnotation == null && extensionContext.getRequiredTestClass() != null) {
issueAnnotation = extensionContext.getRequiredTestClass().getAnnotation(Issue.class);
}
if (issueAnnotation != null && issueAnnotation.fixed()) {
if (issueAnnotation != null && !issueAnnotation.fixed()) {
try {
invocation.proceed();
} catch (AssertionError exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import com.avaloq.tools.ddk.test.core.Issue;
import com.avaloq.tools.ddk.test.core.jupiter.IssueAwareRule;
import com.avaloq.tools.ddk.test.ui.swtbot.SwtWorkbenchBot;
import com.avaloq.tools.ddk.test.ui.swtbot.util.PreferenceUtil;

Expand All @@ -29,11 +26,6 @@
@SuppressWarnings("nls")
public class SwtBotRadioTest {

@RegisterExtension
// CHECKSTYLE:CHECK-OFF VisibilityModifier
public final IssueAwareRule rule = IssueAwareRule.getInstance();
// CHECKSTYLE:CHECK-ON VisibilityModifier

private static final String[] PREFERENCES_PATH = new String[] {"General", "Perspectives"};

/**
Expand Down Expand Up @@ -69,7 +61,6 @@ public void testSwtRadioButtonClick() {
* Test if the method {@link org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio#click()} works correctly.
*/
@Test
@Issue(value = "DSL-371", fixed = false)
public void testSWTRadioButtonClick() {
SWTWorkbenchBot bot = new SWTWorkbenchBot();
bot.resetWorkbench();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.avaloq.tools.ddk.xtext.builder.ContainerStateTest;
import com.avaloq.tools.ddk.xtext.builder.XtextBuildTriggerTest;
import com.avaloq.tools.ddk.xtext.builder.resourceloader.ParallelResourceLoaderTest;
import com.avaloq.tools.ddk.xtext.jupiter.IssueAwareRuleTest;
import com.avaloq.tools.ddk.xtext.jupiter.formatter.FormatterTest;
import com.avaloq.tools.ddk.xtext.linking.AbstractFragmentProviderTest;
import com.avaloq.tools.ddk.xtext.linking.FragmentIndexParsingTest;
Expand Down Expand Up @@ -72,7 +73,8 @@
PrefixedContainerScopeTest.class,
FragmentIndexParsingTest.class,
SelectorFragmentIndexTest.class,
PatternAwareEObjectDescriptionLookUpConcurrencyTest.class})
PatternAwareEObjectDescriptionLookUpConcurrencyTest.class,
IssueAwareRuleTest.class})
// @Format-On
public class XtextTestSuite {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*******************************************************************************
* Copyright (c) 2026 Avaloq Group AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Avaloq Group AG - initial API and implementation
*******************************************************************************/
package com.avaloq.tools.ddk.xtext.jupiter;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.InvocationInterceptor.Invocation;
import org.junit.jupiter.api.function.Executable;

import com.avaloq.tools.ddk.test.core.Issue;
import com.avaloq.tools.ddk.test.core.jupiter.IssueAwareRule;


/**
* Tests that {@link IssueAwareRule} inverts the result of tests for not fixed issues only.
*/
@SuppressWarnings("nls")
public class IssueAwareRuleTest {

private static final String NOT_FIXED = "notFixed";
private static final String FIXED = "fixed";

private static final Invocation<Void> PASSING = () -> null;
private static final Invocation<Void> FAILING = () -> {
throw new AssertionError("test failure");
};
private static final Invocation<Void> ERRONEOUS = () -> {
throw new IllegalStateException("test error");
};

/**
* Declares the annotated methods the rule reads.
*/
private interface Fixtures {
@Issue(value = "ISSUE-42", fixed = false)
void notFixed();

@Issue("ISSUE-42")
void fixed();
}

/**
* Creates the call of the rule for a test with the annotation of the given fixture.
*
* @param fixture
* the name of the {@link Fixtures} method, must not be {@code null}
* @param test
* the test the rule intercepts, must not be {@code null}
* @return the call of the rule, never {@code null}
* @throws NoSuchMethodException
* if the fixture does not exist
*/
private static Executable intercept(final String fixture, final Invocation<Void> test) throws NoSuchMethodException {
ExtensionContext context = mock(ExtensionContext.class);
when(context.getRequiredTestMethod()).thenReturn(Fixtures.class.getMethod(fixture));
doReturn(Fixtures.class).when(context).getRequiredTestClass();
return () -> IssueAwareRule.getInstance().interceptTestMethod(test, null, context);
}

@Test
public void testNotFixedIssueWithFailingTestPasses() throws NoSuchMethodException {
assertDoesNotThrow(intercept(NOT_FIXED, FAILING));
}

@Test
public void testNotFixedIssueWithPassingTestFails() throws NoSuchMethodException {
assertThrows(AssertionError.class, intercept(NOT_FIXED, PASSING));
}

@Test
public void testNotFixedIssueWithErroneousTestReportsError() throws NoSuchMethodException {
assertThrows(IllegalStateException.class, intercept(NOT_FIXED, ERRONEOUS));
}

@Test
public void testFixedIssueWithPassingTestPasses() throws NoSuchMethodException {
assertDoesNotThrow(intercept(FIXED, PASSING));
}

@Test
public void testFixedIssueWithFailingTestFails() throws NoSuchMethodException {
assertThrows(AssertionError.class, intercept(FIXED, FAILING));
}
}