Package org.mockito.internal.exceptions.util

Source Code of org.mockito.internal.exceptions.util.ScenarioPrinterTest

/*
* Copyright (c) 2007 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package org.mockito.internal.exceptions.util;

import static java.util.Arrays.*;

import java.util.List;

import org.junit.Test;
import org.mockito.internal.invocation.InvocationBuilder;
import org.mockito.invocation.Invocation;
import org.mockitoutil.TestBase;

@SuppressWarnings("unchecked")
public class ScenarioPrinterTest extends TestBase {

    ScenarioPrinter sp = new ScenarioPrinter();
   
    @Test
    public void shouldPrintInvocations() {
        //given
        Invocation verified = new InvocationBuilder().simpleMethod().verified().toInvocation();
        Invocation unverified = new InvocationBuilder().differentMethod().toInvocation();
       
        //when
        String out = sp.print((List) asList(verified, unverified));
       
        //then
        assertContains("1. -> at", out);
        assertContains("2. [?]-> at", out);
    }
   
    @Test
    public void shouldNotPrintInvocationsWhenSingleUnwanted() {
        //given
        Invocation unverified = new InvocationBuilder().differentMethod().toInvocation();
       
        //when
        String out = sp.print((List) asList(unverified));
       
        //then
        assertContains("Actually, above is the only interaction with this mock.", out);
    }
}
TOP

Related Classes of org.mockito.internal.exceptions.util.ScenarioPrinterTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.