• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fslev / cucumber-jutils / #287

05 May 2026 01:59PM UTC coverage: 87.5% (-1.9%) from 89.399%
#287

push

fslevoaca-ionos
Migrate to Java 17, JUnit Jupiter 6, and Mockito 5; refactor internals with modern Java idioms

73 of 84 new or added lines in 7 files covered. (86.9%)

4 existing lines in 1 file now uncovered.

245 of 280 relevant lines covered (87.5%)

0.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.43
/src/main/java/com/cucumber/utils/context/steps/MatchSteps.java
1
package com.cucumber.utils.context.steps;
2

3
import com.cucumber.utils.context.ScenarioUtils;
4
import com.cucumber.utils.context.ScenarioVarsUtils;
5
import com.cucumber.utils.context.vars.ScenarioVars;
6
import com.google.inject.Inject;
7
import io.cucumber.guice.ScenarioScoped;
8
import io.cucumber.java.en.Then;
9
import io.json.compare.util.MessageUtil;
10
import io.jtest.utils.matcher.ObjectMatcher;
11
import io.jtest.utils.matcher.condition.MatchCondition;
12

13
import java.util.List;
14
import java.util.Map;
15

16
@ScenarioScoped
17
public class MatchSteps {
1✔
18

19
    private static final String MATCH_LOG = """
20
            MATCH:
21

22
            {}
23

24
            against:
25

26
            {}""";
27

28
    private static final String MATCH_WITH_CONDITIONS_LOG = """
29
            MATCH:
30

31
            {}
32

33
            against:
34

35
            {}
36
                with match conditions: {}""";
37

38
    private static final String NEGATIVE_MATCH_LOG = """
39
            Negative match:
40

41
            {}
42

43
            against:
44

45
            {}""";
46

47
    @Inject
48
    private ScenarioVars scenarioVars;
49
    @Inject
50
    private ScenarioUtils logger;
51

52
    @Then("[util] Match {} with {}")
53
    public void match(Object expected, Object actual) {
54
        logger.log(MATCH_LOG, expected, cropped(actual));
1✔
55
        scenarioVars.putAll(ObjectMatcher.match(null, expected, actual));
1✔
56
    }
1✔
57

58
    @Then("[util] Match {} against")
59
    public void matchWithDocString(Object expected, StringBuilder actual) {
60
        match(expected, actual.toString());
1✔
61
    }
1✔
62

63
    @Then("[util] Match {} against {} using matchConditions={}")
64
    public void match(Object expected, Object actual, MatchCondition[] matchConditions) {
65
        logger.log(MATCH_WITH_CONDITIONS_LOG, expected, cropped(actual), matchConditions);
1✔
66
        scenarioVars.putAll(ObjectMatcher.match(null, expected, actual, matchConditions));
1✔
67
    }
1✔
68

69
    @Then("[util] Match {} against file \"{}\"")
70
    public void matchWithContentFromFilepath(Object expected, String filePath) {
71
        match(expected, ScenarioVarsUtils.parse(filePath, scenarioVars));
1✔
72
    }
1✔
73

74
    @Then("[util] Match {} against table")
75
    public void matchWithDataTable(Object expected, List<Map<String, Object>> actual) {
76
        logger.log(MATCH_LOG, expected, actual);
1✔
77
        scenarioVars.putAll(ObjectMatcher.match(null, expected, actual));
1✔
78
    }
1✔
79

80
    @Then("[util] Match {} against NULL")
81
    public void matchWithNull(Object expected) {
82
        logger.log(MATCH_LOG, expected, null);
1✔
83
        if (expected != null) {
1✔
NEW
84
            throw new AssertionError("Expected null but was: " + expected);
×
85
        }
86
    }
1✔
87

88
    @Then("[util] Negative match {} with {}")
89
    public void matchNegativeWithString(Object expected, Object actual) {
90
        logger.log(NEGATIVE_MATCH_LOG, expected, cropped(actual));
1✔
91
        try {
92
            scenarioVars.putAll(ObjectMatcher.match(null, expected, actual));
1✔
93
        } catch (AssertionError e) {
1✔
94
            logger.log("Assertion Error caught. Negative match passes {}", e.getMessage());
1✔
95
            return;
1✔
96
        }
1✔
97
        throw new AssertionError("Objects match");
1✔
98
    }
99

100
    @Then("[util] Negative match {} against")
101
    public void matchNegativeWithDocString(Object expected, StringBuilder actual) {
102
        matchNegativeWithString(expected, actual.toString());
1✔
103
    }
1✔
104

105
    private static String cropped(Object value) {
106
        return value != null ? MessageUtil.cropL(value.toString()) : null;
1✔
107
    }
108
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc