All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.junit.jupiter.api.DynamicContainer Maven / Gradle / Ivy

There is a newer version: 5.11.0-M1
Show newest version
/*
 * Copyright 2015-2018 the original author or authors.
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v2.0 which
 * accompanies this distribution and is available at
 *
 * http://www.eclipse.org/legal/epl-v20.html
 */

package org.junit.jupiter.api;

import static org.apiguardian.api.API.Status.EXPERIMENTAL;

import java.util.stream.Stream;
import java.util.stream.StreamSupport;

import org.apiguardian.api.API;
import org.junit.platform.commons.util.Preconditions;

/**
 * A {@code DynamicContainer} is a container generated at runtime.
 *
 * 

It is composed of a {@linkplain #getDisplayName display name} and an * iterable of {@link DynamicNode}s. * *

Instances of {@code DynamicContainer} must be generated by factory methods * annotated with {@link TestFactory @TestFactory}. * * @since 5.0 */ @API(status = EXPERIMENTAL, since = "5.0") public class DynamicContainer extends DynamicNode { /** * Factory for creating a new {@code DynamicContainer} for the supplied display * name and a collection of dynamic nodes. * *

The collection of dynamic nodes must not contain {@code null} elements. * * @param displayName the display name for the dynamic container; never * {@code null} or blank * @param dynamicNodes collection of dynamic nodes to execute; * never {@code null} */ public static DynamicContainer dynamicContainer(String displayName, Iterable dynamicNodes) { return new DynamicContainer(displayName, StreamSupport.stream(dynamicNodes.spliterator(), false)); } /** * Factory for creating a new {@code DynamicContainer} for the supplied display * name and a stream of dynamic nodes. * *

The stream of dynamic nodes must not contain {@code null} elements. * * @param displayName the display name for the dynamic container; never * {@code null} or blank * @param dynamicNodes stream of dynamic nodes to execute; * never {@code null} */ public static DynamicContainer dynamicContainer(String displayName, Stream dynamicNodes) { return new DynamicContainer(displayName, dynamicNodes); } private final Stream children; private DynamicContainer(String displayName, Stream children) { super(displayName); Preconditions.notNull(children, "children must not be null"); this.children = children; } /** * Get the {@link Stream} of {@link DynamicNode DynamicNodes} associated * with this container. */ public Stream getChildren() { return children; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy