From d85f1640d70ab55243d4677c17bb02c88443954c Mon Sep 17 00:00:00 2001 From: dhruba619 Date: Sun, 2 Apr 2017 16:35:58 +0530 Subject: [PATCH] BAEL-716 Junit vs testng improvement --- .../baeldung/junit4vstestng/SortedTests.java | 25 +++++++++++++++++++ .../test/java/baeldung/com/PriorityTest.java | 23 +++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 core-java/src/test/java/com/baeldung/junit4vstestng/SortedTests.java create mode 100644 testng/src/test/java/baeldung/com/PriorityTest.java diff --git a/core-java/src/test/java/com/baeldung/junit4vstestng/SortedTests.java b/core-java/src/test/java/com/baeldung/junit4vstestng/SortedTests.java new file mode 100644 index 0000000000..1fa4a4e61b --- /dev/null +++ b/core-java/src/test/java/com/baeldung/junit4vstestng/SortedTests.java @@ -0,0 +1,25 @@ +package com.baeldung.junit4vstestng; + +import static org.junit.Assert.assertTrue; + +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class SortedTests { + + @Test + public void a_givenString_whenChangedtoInt_thenTrue(){ + assertTrue( + Integer.valueOf("10") instanceof Integer); + } + + @Test + public void b_givenInt_whenChangedtoString_thenTrue(){ + assertTrue( + String.valueOf(10) instanceof String); + } + +} diff --git a/testng/src/test/java/baeldung/com/PriorityTest.java b/testng/src/test/java/baeldung/com/PriorityTest.java new file mode 100644 index 0000000000..34f2d6fe47 --- /dev/null +++ b/testng/src/test/java/baeldung/com/PriorityTest.java @@ -0,0 +1,23 @@ +package baeldung.com; + +import org.testng.Assert; +import org.testng.annotations.Test; + +public class PriorityTest { + + private String testString = "10"; + private int testInt = 23; + + @Test(priority = 1) + public void givenString_whenChangedToInt_thenCorrect() { + Assert.assertTrue( + Integer.valueOf(testString) instanceof Integer); + } + + @Test(priority = 2) + public void givenInt_whenChangedToString_thenCorrect() { + Assert.assertTrue( + String.valueOf(testInt) instanceof String); + } + +}