summaryrefslogtreecommitdiff
path: root/plugins/InspectionGadgets/testsrc/com/siyeh/ig/junit/ExpectedExceptionNeverThrownInspectionTest.java
blob: e057666843c8fb8fcb89ac4ef6f9c576ee00f010 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
 * (c) 2013 Desert Island BV
 * created: 14 08 2013
 */
package com.siyeh.ig.junit;

import com.intellij.codeInspection.LocalInspectionTool;
import com.siyeh.ig.LightInspectionTestCase;

/**
 * @author Bas Leijdekkers
 */
public class ExpectedExceptionNeverThrownInspectionTest extends LightInspectionTestCase {
  @Override
  protected LocalInspectionTool getInspection() {
    return new ExpectedExceptionNeverThrownInspection();
  }

  @Override
  protected String[] getEnvironmentClasses() {
    return new String[] {"package org.junit; " +
                         "public @interface Test {\n" +
                         "    java.lang.Class<? extends java.lang.Throwable> expected() default org.junit.Test.None.class;" +
                         "}"};
  }

  public void testSimple() {
    doTest("class X {" +
           "    @org.junit.Test(expected=/*Expected 'java.io.IOException' never thrown in body of 'test()'*/java.io.IOException/**/.class)" +
           "    public void test() {}" +
           "}");
  }

  public void testError() {
    doTest("class X {" +
           "    @org.junit.Test(expected = Error.class)" +
           "    public void test() {}" +
           "}");
  }

  public void testRuntimeException() {
    doTest("class X {" +
           "    @org.junit.Test(expected = IllegalArgumentException.class)" +
           "    public void test() {}" +
           "}");
  }
}