// Path: src/test/java/com/github/kolorobot/exceptions/MyCheckedException.java
// public class MyCheckedException extends Exception {
//     public MyCheckedException() {
//         super("My custom checked exception");
//     }
// }
// 
// Path: src/test/java/com/github/kolorobot/exceptions/MyRuntimeException.java
// public class MyRuntimeException extends RuntimeException {
// 
//     private int code = 0;
// 
//     public MyRuntimeException() {
//         super("My custom runtime exception");
//     }
// 
//     public MyRuntimeException(int code) {
//         this.code = code;
//     }
// 
//     public MyRuntimeException(Throwable cause) {
//         super("My custom runtime exception", cause);
//     }
// 
//     public int getCode() {
//         return code;
//     }
// }
// 
// Path: src/test/java/com/github/kolorobot/exceptions/Thrower.java
// public class Thrower {
//     public void throwsRuntime() {
//         throw new MyRuntimeException();
//     }
// 
//     public void throwsRuntimeWithCause() {
//         throw new MyRuntimeException(new IllegalStateException("Illegal state"));
//     }
// 
//     public void throwsRuntimeWithCode(int code) {
//         throw new MyRuntimeException(code);
//     }
// 
//     public void throwsChecked() throws MyCheckedException {
//         throw new MyCheckedException();
//     }
// 
//     public void throwsRuntimeInsteadOfChecked() throws MyCheckedException {
//         throw new MyRuntimeException();
//     }
// }


import com.github.kolorobot.exceptions.MyCheckedException;
import com.github.kolorobot.exceptions.MyRuntimeException;
import com.github.kolorobot.exceptions.Thrower;
import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import static org.hamcrest.CoreMatchers.startsWith;
package com.github.kolorobot.exceptions.junit4rule;



public class Junit4RuleExceptionsTest {

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

    private Thrower thrower = new Thrower();

    @Test
    public void verifiesTypeAndMessage() {
        thrown.expect(MyRuntimeException.class);
        thrown.expectMessage("My custom runtime exception");

        thrower.throwsRuntime();
    }

    @Test
    public void throwsDifferentExceptionThanExpected() throws MyCheckedException {
        thrown.expect(MyCheckedException.class);
        thrown.expectMessage("Expected exception to be thrown");

        thrower.throwsRuntimeInsteadOfChecked();
    }

    @Test
    public void doesNotThrowExpectedException() {
// Path: src/test/java/com/github/kolorobot/exceptions/MyCheckedException.java
// public class MyCheckedException extends Exception {
//     public MyCheckedException() {
//         super("My custom checked exception");
//     }
// }
// 
// Path: src/test/java/com/github/kolorobot/exceptions/MyRuntimeException.java
// public class MyRuntimeException extends RuntimeException {
// 
//     private int code = 0;
// 
//     public MyRuntimeException() {
//         super("My custom runtime exception");
//     }
// 
//     public MyRuntimeException(int code) {
//         this.code = code;
//     }
// 
//     public MyRuntimeException(Throwable cause) {
//         super("My custom runtime exception", cause);
//     }
// 
//     public int getCode() {
//         return code;
//     }
// }
// 
// Path: src/test/java/com/github/kolorobot/exceptions/Thrower.java
// public class Thrower {
//     public void throwsRuntime() {
//         throw new MyRuntimeException();
//     }
// 
//     public void throwsRuntimeWithCause() {
//         throw new MyRuntimeException(new IllegalStateException("Illegal state"));
//     }
// 
//     public void throwsRuntimeWithCode(int code) {
//         throw new MyRuntimeException(code);
//     }
// 
//     public void throwsChecked() throws MyCheckedException {
//         throw new MyCheckedException();
//     }
// 
//     public void throwsRuntimeInsteadOfChecked() throws MyCheckedException {
//         throw new MyRuntimeException();
//     }
// }


// Path: src/test/java/com/github/kolorobot/exceptions/junit4rule/Junit4RuleExceptionsTest.java
import com.github.kolorobot.exceptions.MyCheckedException;
import com.github.kolorobot.exceptions.MyRuntimeException;
import com.github.kolorobot.exceptions.Thrower;
import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import static org.hamcrest.CoreMatchers.startsWith;

package com.github.kolorobot.exceptions.junit4rule;



public class Junit4RuleExceptionsTest {

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

    private Thrower thrower = new Thrower();

    @Test
    public void verifiesTypeAndMessage() {
        thrown.expect(MyRuntimeException.class);
        thrown.expectMessage("My custom runtime exception");

        thrower.throwsRuntime();
    }

    @Test
    public void throwsDifferentExceptionThanExpected() throws MyCheckedException {
        thrown.expect(MyCheckedException.class);
        thrown.expectMessage("Expected exception to be thrown");

        thrower.throwsRuntimeInsteadOfChecked();
    }

    @Test
    public void doesNotThrowExpectedException() {
        thrown.expect(MyRuntimeException.class);