Skip to content

Commit

Permalink
using DynamicContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
musketyr committed May 27, 2024
1 parent dc01f01 commit 7a80724
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.agorapulse.testing.where4j;

import com.agorapulse.testing.where4j.dsl.*;
import org.junit.jupiter.api.DynamicTest;
import com.agorapulse.testing.where4j.dsl.Headers3;
import com.agorapulse.testing.where4j.dsl.Row3;
import com.agorapulse.testing.where4j.dsl.Where3;
import org.junit.jupiter.api.DynamicContainer;

import java.util.Arrays;

public interface Expectations extends Iterable<DynamicTest> {
public interface Expectations extends Iterable<DynamicContainer> {

static Headers3 header(String nameA, String nameB, String nameC) {
return new Headers3(nameA, nameB, nameC);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.agorapulse.testing.where4j.dsl;

import com.agorapulse.testing.where4j.Expectations;
import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.DynamicContainer;

import java.util.Collections;
import java.util.Iterator;

class Expectations3<A, B, C> implements Expectations {
Expand All @@ -18,8 +19,8 @@ class Expectations3<A, B, C> implements Expectations {
}

@Override
public Iterator<DynamicTest> iterator() {
return where.generateTests(template, verification);
public Iterator<DynamicContainer> iterator() {
return Collections.singleton(DynamicContainer.dynamicContainer(template, where.generateTests(template, verification))).iterator();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Stream;

public class Where3<A, B , C> {

Expand All @@ -32,7 +32,7 @@ public Expectations verify(String template, Verifcation3<A, B, C> verification)
});
}

Iterator<DynamicTest> generateTests(String template, Assertion3<A, B, C> verification) {
Stream<DynamicTest> generateTests(String template, Assertion3<A, B, C> verification) {
return data.stream().map(row -> {
String title = template.replace("#" + headers.getA(), String.valueOf(row.getA()));
title = title.replace("#" + headers.getB(), String.valueOf(row.getB()));
Expand All @@ -46,6 +46,6 @@ Iterator<DynamicTest> generateTests(String template, Assertion3<A, B, C> verific
}
}
);
}).iterator();
});
}
}

0 comments on commit 7a80724

Please sign in to comment.