Skip to content

Instantly share code, notes, and snippets.

@sahoosunilkumar
Created May 28, 2019 08:24
Show Gist options
  • Save sahoosunilkumar/c10cf00fd68eee58c5111fc499979018 to your computer and use it in GitHub Desktop.
Save sahoosunilkumar/c10cf00fd68eee58c5111fc499979018 to your computer and use it in GitHub Desktop.
Unit Testing for JUnit Annotations
package com.sunilsahoo.unittesting.test;
import org.junit.jupiter.api.*;
class AnnotationTest {
@BeforeAll
static void setup(){
System.out.println("@BeforeAll executed");
}
@BeforeEach
void setupThis(){
System.out.println("@BeforeEach executed");
}
@Tag("DEV")
@Test
void testOne()
{
System.out.println("======TEST ONE EXECUTED=======");
Assertions.assertEquals( "env" , "env");
}
@Tag("PROD")
@Disabled
@Test
void testTwo()
{
System.out.println("======TEST TWO EXECUTED=======");
Assertions.assertEquals( "env" , "env");
}
@Test
void testThree()
{
System.out.println("======TEST THREE EXECUTED=======");
Assertions.assertEquals( "env" , "env");
}
@AfterEach
void tearThis(){
System.out.println("@AfterEach executed");
}
@AfterAll
static void tear(){
System.out.println("@AfterAll executed");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment