Package org.mockitousage.junitrunner

Source Code of org.mockitousage.junitrunner.JUnit45RunnerTest$ListDependent

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

import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static org.mockitousage.junitrunner.Filters.*;

import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

@RunWith(MockitoJUnitRunner.class)
@SuppressWarnings("unchecked")
public class JUnit45RunnerTest {

  @InjectMocks private ListDependent listDependent = new ListDependent();
    @Mock private List list;

    @Test
    public void shouldInitMocksUsingRunner() {
        list.add("test");
        verify(list).add("test");
    }

    @Test
    public void shouldInjectMocksUsingRunner() {
        assertNotNull(list);
        assertSame(list, listDependent.getList());
    }

    @Test
    public void shouldFilterTestMethodsCorrectly() throws Exception{
      MockitoJUnitRunner runner = new MockitoJUnitRunner(this.getClass());

      runner.filter(methodNameContains("shouldInitMocksUsingRunner"));

      assertEquals(1, runner.testCount());
    }

  class ListDependent {
    private List list;

    public List getList() {
      return list;
    }
  }
}
TOP

Related Classes of org.mockitousage.junitrunner.JUnit45RunnerTest$ListDependent

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.