-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start MockitoSession only for test method and BeforeMethod
- Loading branch information
1 parent
949bdac
commit f5a6e08
Showing
8 changed files
with
136 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 16 additions & 9 deletions
25
...itializedBeforeBeforeClassMethodTest.java → ...itializedBeforeBeforeClassMethodTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,37 @@ | ||
/* | ||
* Copyright (c) 2017 Mockito contributors | ||
* Copyright (c) 2021 Mockito contributors | ||
* This program is made available under the terms of the MIT License. | ||
*/ | ||
package org.mockitousage.testng; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.Observer; | ||
|
||
import org.mockito.Mock; | ||
import org.mockito.testng.MockitoTestNGListener; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Listeners; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.Observer; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@Listeners(MockitoTestNGListener.class) | ||
public class EnsureMocksAreInitializedBeforeBeforeClassMethodTest { | ||
public class EnsureMocksAreNotInitializedBeforeBeforeClassMethodTest { | ||
|
||
@Mock Observer observer; | ||
@Mock | ||
Observer observer; | ||
|
||
@BeforeClass | ||
private void make_sure_mock_is_initialized() { | ||
private void make_sure_mock_is_not_initialized() { | ||
assertThat(observer).isNull(); | ||
} | ||
|
||
@Test | ||
public void dummy_test1() { | ||
assertThat(observer).isNotNull(); | ||
} | ||
|
||
@Test | ||
public void dummy_test_see_BeforeClass_code() throws Exception { | ||
public void dummy_test2() { | ||
assertThat(observer).isNotNull(); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...ava/org/mockitousage/testng/EnsureMocksAreNotInitializedBeforeBeforeGroupsMethodTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2021 Mockito contributors | ||
* This program is made available under the terms of the MIT License. | ||
*/ | ||
package org.mockitousage.testng; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.Observer; | ||
|
||
import org.mockito.Mock; | ||
import org.mockito.testng.MockitoTestNGListener; | ||
import org.testng.annotations.BeforeGroups; | ||
import org.testng.annotations.Listeners; | ||
import org.testng.annotations.Test; | ||
|
||
@Listeners(MockitoTestNGListener.class) | ||
public class EnsureMocksAreNotInitializedBeforeBeforeGroupsMethodTest { | ||
|
||
@Mock | ||
Observer observer; | ||
|
||
@BeforeGroups | ||
private void make_sure_mock_is_not_initialized() { | ||
assertThat(observer).isNull(); | ||
} | ||
|
||
@Test | ||
public void dummy_test1() { | ||
assertThat(observer).isNotNull(); | ||
} | ||
|
||
@Test | ||
public void dummy_test2() { | ||
assertThat(observer).isNotNull(); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...java/org/mockitousage/testng/EnsureMocksAreNotInitializedBeforeBeforeSuiteMethodTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2021 Mockito contributors | ||
* This program is made available under the terms of the MIT License. | ||
*/ | ||
package org.mockitousage.testng; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.Observer; | ||
|
||
import org.mockito.Mock; | ||
import org.mockito.testng.MockitoTestNGListener; | ||
import org.testng.annotations.BeforeSuite; | ||
import org.testng.annotations.Listeners; | ||
import org.testng.annotations.Test; | ||
|
||
@Listeners(MockitoTestNGListener.class) | ||
public class EnsureMocksAreNotInitializedBeforeBeforeSuiteMethodTest { | ||
|
||
@Mock | ||
Observer observer; | ||
|
||
@BeforeSuite | ||
private void make_sure_mock_is_not_initialized() { | ||
assertThat(observer).isNull(); | ||
} | ||
|
||
@Test | ||
public void dummy_test1() { | ||
assertThat(observer).isNotNull(); | ||
} | ||
|
||
@Test | ||
public void dummy_test2() { | ||
assertThat(observer).isNotNull(); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
.../java/org/mockitousage/testng/EnsureMocksAreNotInitializedBeforeBeforeTestMethodTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2021 Mockito contributors | ||
* This program is made available under the terms of the MIT License. | ||
*/ | ||
package org.mockitousage.testng; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.Observer; | ||
|
||
import org.mockito.Mock; | ||
import org.mockito.testng.MockitoTestNGListener; | ||
import org.testng.annotations.BeforeTest; | ||
import org.testng.annotations.Listeners; | ||
import org.testng.annotations.Test; | ||
|
||
@Listeners(MockitoTestNGListener.class) | ||
public class EnsureMocksAreNotInitializedBeforeBeforeTestMethodTest { | ||
|
||
@Mock | ||
Observer observer; | ||
|
||
@BeforeTest | ||
private void make_sure_mock_is_not_initialized() { | ||
assertThat(observer).isNull(); | ||
} | ||
|
||
@Test | ||
public void dummy_test1() { | ||
assertThat(observer).isNotNull(); | ||
} | ||
|
||
@Test | ||
public void dummy_test2() { | ||
assertThat(observer).isNotNull(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version=0.2.* | ||
version=0.3.* |