-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
165 additions
and
25 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
testing/testing-testng/src/test/java/com/example/AdditionalTest.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,27 @@ | ||
package com.example; | ||
|
||
import org.testng.Assert; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.Random; | ||
|
||
/** | ||
* @author Ivan Khalopik | ||
* @since 8.0 | ||
*/ | ||
public class AdditionalTest extends Assert { | ||
private Random generator; | ||
|
||
@BeforeClass | ||
public void setUpGenerator() { | ||
generator = new Random(); | ||
} | ||
|
||
@Test(successPercentage = 50, invocationCount = 100) | ||
public void testAdditionalFunctionality() { | ||
if (generator.nextBoolean()) { | ||
fail(); | ||
} | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
testing/testing-testng/src/test/java/com/example/LocaleUtilsTestData.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,26 @@ | ||
package com.example; | ||
|
||
import org.testng.annotations.DataProvider; | ||
|
||
import java.util.Arrays; | ||
import java.util.Locale; | ||
|
||
/** | ||
* @author Ivan Khalopik | ||
* @since 8.0 | ||
*/ | ||
public class LocaleUtilsTestData { | ||
|
||
@DataProvider(name = "getCandidateLocalesData", parallel = true) | ||
public static Object[][] getCandidateLocalesData() { | ||
return new Object[][]{ | ||
{null, Arrays.asList(LocaleUtils.ROOT_LOCALE)}, | ||
{LocaleUtils.ROOT_LOCALE, Arrays.asList(LocaleUtils.ROOT_LOCALE)}, | ||
{ Locale.ENGLISH, Arrays.asList(Locale.ENGLISH, LocaleUtils.ROOT_LOCALE)}, | ||
{Locale.US, Arrays.asList(Locale.US, Locale.ENGLISH, LocaleUtils.ROOT_LOCALE)}, | ||
{new Locale("en", "US", "xxx"), Arrays.asList( | ||
new Locale("en", "US", "xxx"), Locale.US, Locale.ENGLISH, LocaleUtils.ROOT_LOCALE) | ||
}, | ||
}; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
testing/testing-testng/src/test/java/com/example/ParameterizedTest.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,31 @@ | ||
package com.example; | ||
|
||
import org.testng.Assert; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Optional; | ||
import org.testng.annotations.Parameters; | ||
import org.testng.annotations.Test; | ||
|
||
import javax.sql.DataSource; | ||
import java.sql.SQLException; | ||
|
||
/** | ||
* @author Ivan Khalopik | ||
* @since 8.0 | ||
*/ | ||
public class ParameterizedTest extends Assert { | ||
private DataSource dataSource; | ||
|
||
@Parameters({"driver", "url", "username", "password"}) | ||
@BeforeClass | ||
public void setUpDataSource(String driver, String url, @Optional("sa") String username, @Optional String password) { | ||
dataSource = null; | ||
} | ||
|
||
@Test | ||
public void testOptionalData() throws SQLException { | ||
dataSource.getConnection(); | ||
// do some staff | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
testing/testing-testng/src/test/java/com/example/PrioritiesTest.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,29 @@ | ||
package com.example; | ||
|
||
import org.testng.Assert; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
/** | ||
* @author Ivan Khalopik | ||
* @since 8.0 | ||
*/ | ||
public class PrioritiesTest extends Assert { | ||
private boolean firstTestExecuted; | ||
|
||
@BeforeClass | ||
public void setUp() throws Exception { | ||
firstTestExecuted = false; | ||
} | ||
|
||
@Test(priority = 0) | ||
public void first() { | ||
assertFalse(firstTestExecuted); | ||
firstTestExecuted = true; | ||
} | ||
|
||
@Test(priority = 1) | ||
public void second() { | ||
assertTrue(firstTestExecuted); | ||
} | ||
} |
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,43 @@ | ||
<!-- | ||
~ Copyright (c) 2008-2011 Ivan Khalopik. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> | ||
<suite name="Test suite" parallel="classes" thread-count="10"> | ||
<test name="Default tests" verbose="1" annotations="JDK" thread-count="10" parallel="classes"> | ||
<parameter name="driver" value=""/> | ||
<groups> | ||
<run> | ||
<exclude name="integration"/> | ||
</run> | ||
</groups> | ||
|
||
<packages> | ||
<package name="com.example.*"/> | ||
</packages> | ||
</test> | ||
|
||
<test name="Integration tests" annotations="JDK"> | ||
<groups> | ||
<run> | ||
<include name="integration"/> | ||
</run> | ||
</groups> | ||
|
||
<packages> | ||
<package name="com.example.*"/> | ||
</packages> | ||
</test> | ||
</suite> |