Monday 21 June 2021

junit5: Tags: Combine multiple tags

@Tags is a container for one or more @Tag declarations.

 

@Test
@Tag("functional")
@Tag("performance")
public void homePageLoadTest_2() {
	System.out.println("Executing homePageLoadTest");
}

For example, above snippet can be written using @Tags like below

@Test
@Tags({ @Tag("functional"), @Tag("performance") })
public void homePageLoadTest_1() {
	System.out.println("Executing homePageLoadTest");
}


TagsDemo.java

package com.sample.app;

import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Tags;
import org.junit.jupiter.api.Test;

public class TagsDemo {

	@Test
	@Tags({ @Tag("functional"), @Tag("performance") })
	public void homePageLoadTest_1() {
		System.out.println("Executing homePageLoadTest_1");
	}

	@Test
	@Tag("functional")
	@Tag("performance")
	public void homePageLoadTest_2() {
		System.out.println("Executing homePageLoadTest_2");
	}

}


You can download complete working application from this link.

https://github.com/harikrishna553/junit5/tree/master/junit5-examples

 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment