title: RxJava2 with JUnit: no exceptions thrown in tests
body: <p>The code below won't crash when running in JUnit environment. But it crashes when running in the app. I can see error logs in the console, but tests are marked as passed.</p>
  
  <pre><code>  @Test
    public void test() {
      Observable observable = Observable.error(new RuntimeException());
      observable.subscribe();
    }
  </code></pre>
  
  <p>So, the question is: how to make it crash in JUnit. Because yeah, if something doesn't work in the app it's a good thing if it doesn't work in the unit tests also :)</p>
  
  <p>And in this example I have direct access to the observable. But in my real tests I don't have that. Real observables are just internal details of classes that being tested. The most thing I can to do is to inject schedulers or something.</p>
  
  <p>So, how to make it crash without having direct access to the observable?</p>
  
  <p>Also, I've just checked this code doesn't crash either:</p>
  
  <pre><code>  @Test
    public void test() {
      Observable observable = Observable.error(new RuntimeException());
      observable.subscribe(new Consumer() {
        @Override
        public void accept(Object o) throws Exception {
          throw new RuntimeException();
        }
      }, new Consumer&lt;Throwable&gt;() {
        @Override
        public void accept(Throwable throwable) throws Exception {
          throw new RuntimeException();
        }
      });
    }
  </code></pre>