This repository has been archived by the owner on Aug 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow TestNG suite creation only with tests filter
- Loading branch information
Showing
3 changed files
with
58 additions
and
17 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
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,13 +1,12 @@ | ||
package io.github.tatools.sunshine.testng; | ||
|
||
import io.github.tatools.sunshine.core.Condition.Fake; | ||
import io.github.tatools.sunshine.core.SuiteException; | ||
import io.github.tatools.sunshine.core.*; | ||
import org.hamcrest.CustomMatcher; | ||
import org.hamcrest.MatcherAssert; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
import java.util.ArrayList; | ||
|
||
|
||
/** | ||
* @author Dmytro Serdiuk ([email protected]) | ||
|
@@ -21,21 +20,51 @@ public class LoadableTestNGSuiteTest { | |
|
||
@Test | ||
public void testAutomaticSuiteDirectoryCreation() throws SuiteException { | ||
new LoadableTestNGSuite( | ||
ArrayList::new, | ||
this.testFolder.getRoot().getAbsolutePath() + "/custom", | ||
new Fake(true) | ||
).tests(); | ||
MatcherAssert.assertThat( | ||
new LoadableTestNGSuite( | ||
new FileSystem.Fake(), | ||
this.testFolder.getRoot().getAbsolutePath() + "/custom", | ||
new Condition.Fake(true) | ||
).tests(), | ||
new SuiteFileMatcher() | ||
); | ||
} | ||
|
||
@Test | ||
public void testDefaultSuiteDirectoryCreation() throws SuiteException { | ||
new LoadableTestNGSuite(ArrayList::new).tests(); | ||
MatcherAssert.assertThat( | ||
new LoadableTestNGSuite(new SunshineSuite.Fake()).tests(), | ||
new SuiteFileMatcher() | ||
); | ||
} | ||
|
||
|
||
@Test | ||
public void testFileSystemFilteringWithDefaultSuiteFolder() throws SuiteException { | ||
new LoadableTestNGSuite(ArrayList::new, new Fake(true)).tests(); | ||
MatcherAssert.assertThat( | ||
new LoadableTestNGSuite(new FileSystem.Fake(), new Condition.Fake(true)).tests(), | ||
new SuiteFileMatcher() | ||
); | ||
} | ||
|
||
@Test | ||
public void testDefaultTestsFiltering() throws SuiteException { | ||
MatcherAssert.assertThat( | ||
new LoadableTestNGSuite(new Condition.Fake(false)).tests(), | ||
new SuiteFileMatcher() | ||
); | ||
} | ||
|
||
private static class SuiteFileMatcher extends CustomMatcher<File> { | ||
|
||
public SuiteFileMatcher() { | ||
super("Check existence of a suite file"); | ||
} | ||
|
||
@Override | ||
public boolean matches(Object item) { | ||
final File file = (File) item; | ||
return file.exist(); | ||
} | ||
} | ||
} |