Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: added an option to let tests run when projects have errors #398

Merged
merged 8 commits into from
Apr 27, 2023
Prev Previous commit
Next Next commit
fix: set the default value to disable when projects have errors
  • Loading branch information
gtoison committed Apr 15, 2023
commit 7e81eaeede65afa9f541e4b55bef1bc15e31702f
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,35 @@
*/
package org.infinitest.eclipse.prefs;

import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.core.resources.IMarker.SEVERITY_WARNING;
import static org.eclipse.jface.preference.FieldEditor.*;
import static org.infinitest.eclipse.prefs.PreferencesConstants.*;
import static org.infinitest.util.InfinitestGlobalSettings.*;
import static org.eclipse.jface.preference.FieldEditor.IS_VALID;
import static org.eclipse.jface.preference.FieldEditor.VALUE;
import static org.infinitest.eclipse.prefs.PreferencesConstants.AUTO_TEST;
import static org.infinitest.eclipse.prefs.PreferencesConstants.DISABLE_WHEN_WORKSPACE_HAS_ERRORS;
import static org.infinitest.eclipse.prefs.PreferencesConstants.FAILED_TEST_MARKER_SEVERITY;
import static org.infinitest.eclipse.prefs.PreferencesConstants.PARALLEL_CORES;
import static org.infinitest.eclipse.prefs.PreferencesConstants.SLOW_TEST_MARKER_SEVERITY;
import static org.infinitest.eclipse.prefs.PreferencesConstants.SLOW_TEST_WARNING;
import static org.infinitest.util.InfinitestGlobalSettings.getSlowTestTimeLimit;
import static org.infinitest.util.InfinitestGlobalSettings.resetToDefaults;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.*;

import org.eclipse.jface.preference.*;
import org.eclipse.jface.util.*;
import org.eclipse.swt.*;
import org.infinitest.eclipse.*;
import org.infinitest.eclipse.markers.*;
import org.infinitest.eclipse.trim.*;
import org.infinitest.eclipse.workspace.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;

import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
import org.infinitest.eclipse.PluginActivationController;
import org.infinitest.eclipse.markers.ProblemMarkerRegistry;
import org.infinitest.eclipse.markers.SlowMarkerRegistry;
import org.infinitest.eclipse.trim.ColorSettings;
import org.infinitest.eclipse.workspace.CoreSettings;
import org.infinitest.util.InfinitestGlobalSettings;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -157,6 +171,17 @@ void shouldIgnoreBlankValues() {
when(eventSource.getPreferenceName()).thenReturn(PARALLEL_CORES);
assertDoesNotThrow(() -> changeProperty(VALUE, "", ""));
}

@Test
void updateDisableWhenWorkspaceHasErrors() {
when(eventSource.getPreferenceName()).thenReturn(DISABLE_WHEN_WORKSPACE_HAS_ERRORS);

changeProperty(VALUE, true, false);
assertThat(InfinitestGlobalSettings.isDisableWhenWorkspaceHasErrors()).isFalse();

changeProperty(VALUE, false, true);
assertThat(InfinitestGlobalSettings.isDisableWhenWorkspaceHasErrors()).isTrue();
}

private void changeProperty(String type, Object oldValue, Object newValue) {
handler.propertyChange(new PropertyChangeEvent(eventSource, type, oldValue, newValue));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
public class InfinitestGlobalSettings {
private static Level logLevel = Level.INFO;
private static long slowTestTimeLimit = 500;
private static boolean disableWhenWorkspaceHasErrors;
private static boolean disableWhenWorkspaceHasErrors = true;

public static void resetToDefaults() {
setLogLevel(INFO);
Expand Down