NOVA-Team / NOVA-Monorepo

The core API of the NOVA voxel game modding system
https://nova-team.github.io
GNU Lesser General Public License v3.0
66 stars 23 forks source link

Rewrote exception throwing tests in EnumSelectorTest properly #236

Closed ExE-Boss closed 7 years ago

ExE-Boss commented 7 years ago

It turns out, the way I wrote the exception throwing tests previously is an ugly hack. Instead, I was supposed to do it the way I’ve done it now.

Correct way:

@Test(expected = ExampleException.class)
public void test() {
    throw new ExampleException();
}

or

@Rule
public ExpectedException thrown = ExpectedException.none();

@Test
public void test() {
    thrown.expect(ExampleException.class);
    throw new ExampleException();
}

Ugly hack way:

@Test
public void test() {
    ExampleException result = null;
    try {
        throw new ExampleException();
    } catch (ExampleException ex) {
        result = ex;
    }
    assertThat(result).isNotNull();
}
codecov-io commented 7 years ago

Current coverage is 13.75% (diff: 100%)

Merging #236 into master will not change coverage

@@             master       #236   diff @@
==========================================
  Files           387        387          
  Lines         10839      10839          
  Methods           0          0          
  Messages          0          0          
  Branches       1547       1547          
==========================================
  Hits           1491       1491          
  Misses         9271       9271          
  Partials         77         77          

Powered by Codecov. Last update 70a4f22...15a68b1

RX14 commented 7 years ago

:ok_hand: