Skip to content

Commit

Permalink
Fix spurious test failures (wpilibsuite#338)
Browse files Browse the repository at this point in the history
* Fix spurious test failures with AllWidgetSanityTest

Were caused by values being set on the FX Thread instead of the test thread
Still no idea why it was only for the tests for PIDCommand and Graph widgets

* Fix spurious failure with NumberFieldTest

Was caused by clearing the field when not on the FX thread
  • Loading branch information
SamCarlberg authored Jan 4, 2018
1 parent 6c2bf60 commit 7227fe1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void start(Stage stage) throws Exception {

@Test
public void numberPropertyIsUpdatedTest() {
numberField.clear();
interact(numberField::clear);
clickOn(".text-field").write("123.456");

assertEquals(123.456, numberField.numberProperty().getValue().doubleValue());
Expand All @@ -32,7 +32,7 @@ public void numberPropertyIsUpdatedTest() {
@ParameterizedTest
@ValueSource(strings = {"0.0", "1.0", "12.56", "-0", "-1", "-10", "+0", "+55.99", "-54.21"})
public void validNumberTest(String number) {
numberField.clear();
interact(numberField::clear);
clickOn(".text-field").write(number);

assertEquals(Double.parseDouble(number), numberField.getNumber().doubleValue());
Expand All @@ -45,7 +45,7 @@ public void validNumberTest(String number) {
"0.0, 0.......0",
"0.0, 0.0."})
public void invalidNumberTest(String expectedResult, String test) {
numberField.clear();
interact(numberField::clear);
clickOn(".text-field").write(test);

assertEquals(expectedResult, numberField.getText());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import edu.wpi.first.shuffleboard.api.data.DataType;
import edu.wpi.first.shuffleboard.api.data.DataTypes;
import edu.wpi.first.shuffleboard.api.sources.DummySource;
import edu.wpi.first.shuffleboard.api.util.AsyncUtils;
import edu.wpi.first.shuffleboard.api.util.FxUtils;
import edu.wpi.first.shuffleboard.api.util.TypeUtils;
import edu.wpi.first.shuffleboard.api.widget.Widget;
import edu.wpi.first.shuffleboard.api.widget.WidgetType;
Expand All @@ -28,13 +30,15 @@ public class AllWidgetSanityTest extends ApplicationTest {

@BeforeAll
public static void setup() {
AsyncUtils.setAsyncRunner(Runnable::run);
DataTypes.setDefault(new DataTypes());
plugin.getDataTypes().forEach(DataTypes.getDefault()::register);
}

@AfterAll
public static void tearDown() {
DataTypes.setDefault(new DataTypes());
AsyncUtils.setAsyncRunner(FxUtils::runOnFxThread);
}

@ParameterizedTest
Expand Down

0 comments on commit 7227fe1

Please sign in to comment.