Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private void sendParameterEvent(final ReflectiveInvocationContext<Method> invoca

final Class<?> parameterType = parameter.getType();
// Skip default jupiter injectables as TestInfo, TestReporter and TempDirectory
if (parameterType.getPackage().getName().startsWith("org.junit.jupiter.api")) {
if (parameterType.getCanonicalName().startsWith("org.junit.jupiter.api")) {
continue;
}
final Object value = invocationContext.getArguments().get(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.qameta.allure.junit5.features.AllFixtureSupport;
import io.qameta.allure.junit5.features.BeforeEachFixtureFailureSupport;
import io.qameta.allure.junit5.features.EachFixtureSupport;
import io.qameta.allure.junit5.features.ParameterisedPrimitivesTests;
import io.qameta.allure.junit5.features.ParameterisedTests;
import io.qameta.allure.junit5.features.SkipOtherInjectables;
import io.qameta.allure.junitplatform.AllureJunitPlatform;
Expand Down Expand Up @@ -54,9 +55,41 @@
* @author charlie (Dmitry Baev).
*/
@AllureFeatures.Fixtures
@SuppressWarnings("unchecked")
class AllureJunit5Test {

@Test
void shouldSupportPrimitiveTypeParameters() {
final AllureResults results = runClasses(ParameterisedPrimitivesTests.class);
assertThat(results.getTestResults())
.extracting(TestResult::getName, tr -> tr.getParameters().size())
.containsExactlyInAnyOrder(
tuple("booleansMethodSource(boolean, boolean) [1] a=true, b=true", 3),
tuple("booleansMethodSource(boolean, boolean) [2] a=true, b=false", 3),
tuple("booleansMethodSource(boolean, boolean) [3] a=false, b=true", 3),
tuple("booleansMethodSource(boolean, boolean) [4] a=false, b=false", 3),
tuple("floats(float) [1] value=0.1", 2),
tuple("floats(float) [2] value=0.01", 2),
tuple("shorts(int) [1] value=1", 2),
tuple("shorts(int) [2] value=2", 2),
tuple("shorts(int) [3] value=3", 2),
tuple("ints(int) [1] value=1", 2),
tuple("ints(int) [2] value=2", 2),
tuple("ints(int) [3] value=3", 2),
tuple("bytes(byte) [1] value=0", 2),
tuple("bytes(byte) [2] value=1", 2),
tuple("chars(char) [1] value=a", 2),
tuple("chars(char) [2] value=b", 2),
tuple("chars(char) [3] value=c", 2),
tuple("longs(long) [1] value=0", 2),
tuple("longs(long) [2] value=1", 2),
tuple("nullMethodSource(String) [1] value=null", 2),
tuple("doubles(double) [1] value=0.1", 2),
tuple("doubles(double) [2] value=0.01", 2),
tuple("booleans(boolean) [1] value=true", 2),
tuple("booleans(boolean) [2] value=false", 2)
);
}

@Test
void shouldSupportParametersForParameterisedTests() {
final AllureResults results = runClasses(ParameterisedTests.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Copyright 2019 Qameta Software OÜ
*
* 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.
*/
package io.qameta.allure.junit5.features;

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;

import java.util.stream.Stream;

/**
* @author charlie (Dmitry Baev).
*/
public class ParameterisedPrimitivesTests {

@ParameterizedTest
@ValueSource(bytes = {0, 1})
void bytes(byte value) {
}

@ParameterizedTest
@ValueSource(shorts = {1, 2, 3})
void shorts(int value) {
}

@ParameterizedTest
@ValueSource(ints = {1, 2, 3})
void ints(int value) {
}

@ParameterizedTest
@ValueSource(longs = {0L, 1L})
void longs(long value) {
}

@ParameterizedTest
@ValueSource(floats = {0.1f, 0.01f})
void floats(float value) {
}

@ParameterizedTest
@ValueSource(doubles = {0.1d, 0.01d})
void doubles(double value) {
}

@ParameterizedTest
@ValueSource(chars = {'a', 'b', 'c'})
void chars(char value) {
}

@ParameterizedTest
@ValueSource(booleans = {true, false})
void booleans(boolean value) {
}

@ParameterizedTest
@MethodSource("arguments")
void booleansMethodSource(final boolean a, final boolean b) {
}

@ParameterizedTest
@MethodSource("nulls")
void nullMethodSource(final String value) {
}

static Stream<Arguments> arguments() {
return Stream.of(
Arguments.of(true, true),
Arguments.of(true, false),
Arguments.of(false, true),
Arguments.of(false, false)
);
}

static Stream<Arguments> nulls() {
return Stream.of(
Arguments.of((String) null)
);
}


}