Why doesn't solo_group call it's setUp method

89 Views Asked by At

I'm using scheduled_test to test my Polymer Dart elements. This works fine, until I try using solo_group(). My tests depend on the setUp() method being called, but when solo_group() is used, the setUp() method is not called. My tests, understandable fail, throwing errors about null values. Is there a reason for this? I tried using solo_test() instead, and this worked as I expected, calling the setUp() method, as it should, but not the solo_group.

I feel another bug report, but I want to confirm this is not the expected behaviour, before I do.

{UPDATE} As asked, here is an example, which isn't all the test code, but it should suffice. With this example, I expect the setUp() method to be called, but it isn't. However if I turn solo_group to just group, it does. setUp() also will be called if test() is replaced with solo_test(), and solo_group() is replaced with group().

class CheckedFieldComponent extends PageComponent {
  CheckedFieldComponent(el) : super(el);

  bool get value => component.model.value;
  bool get checkIconShown => component.shadowRoot.querySelector('core-icon') != null;
}

void checked_field_test() {
  CheckedFieldComponent component;
  CheckedFieldComponent component2;

  solo_group('[checked-field]', () {
    setUp(() {
      schedule(() => Polymer.onReady);
      schedule(() {
        BoolModel model = new Model.create('bool', '1', 'checked', true, true);
        BoolModel model2 = new Model.create('bool', '2', 'checked', false, true);

        PolymerElement element = createElement('<checked-field></checked-field>');
        PolymerElement element2 = createElement('<checked-field></checked-field>');

        element.model = model;
        element2.model = model2;

        document.body.append(element);
        document.body.append(element2);

        component = new CheckedFieldComponent(element);
        component2 = new CheckedFieldComponent(element2);

        return Future.wait([component.flush(), component2.flush()]);
      });
      currentSchedule.onComplete.schedule(() {
        component.component.remove();
        component2.component.remove();
      });
    });


    test('model.value is true', () {
      schedule(() {
        expect(component.value, isTrue);
      });
    });
  });
}
0

There are 0 best solutions below