From 6294ad0e3578b285b9d6767beb2a90d44ea6971e Mon Sep 17 00:00:00 2001 From: Toby Date: Tue, 29 Oct 2019 08:15:42 +0000 Subject: [PATCH] #14 improve description for multiple regions --- .../robot/excel/matchers/MergedRegionsMatcher.java | 2 +- .../excel/matchers/MergedRegionsMatcherTest.java | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/bad/robot/excel/matchers/MergedRegionsMatcher.java b/src/main/java/bad/robot/excel/matchers/MergedRegionsMatcher.java index 169e0a3..719fb88 100644 --- a/src/main/java/bad/robot/excel/matchers/MergedRegionsMatcher.java +++ b/src/main/java/bad/robot/excel/matchers/MergedRegionsMatcher.java @@ -56,7 +56,7 @@ public void describeTo(Description description) { } private String mergedRegion(Sheet sheet) { - return sheet.getMergedRegions().stream().map(CellRangeAddress::formatAsString).collect(Collectors.joining()); + return sheet.getMergedRegions().stream().map(CellRangeAddress::formatAsString).collect(Collectors.joining(", ")); } } diff --git a/src/test/java/bad/robot/excel/matchers/MergedRegionsMatcherTest.java b/src/test/java/bad/robot/excel/matchers/MergedRegionsMatcherTest.java index 58a1558..ecfb63d 100644 --- a/src/test/java/bad/robot/excel/matchers/MergedRegionsMatcherTest.java +++ b/src/test/java/bad/robot/excel/matchers/MergedRegionsMatcherTest.java @@ -32,13 +32,15 @@ public class MergedRegionsMatcherTest { private Sheet sheetWithMergedRegions; - private Sheet sheetWithMergedRegionsAltText; private Sheet sheetWithAltMergedRegion; + private Sheet sheetWithTwoMergedRegion; + private Sheet sheetWithMergedRegionsAltText; @Before public void loadWorkbookAndSheets() throws IOException { sheetWithMergedRegions = firstSheetOf("mergedRegionSheet.xlsx"); sheetWithAltMergedRegion = firstSheetOf("mergedRegionWithAltRegion.xlsx"); + sheetWithTwoMergedRegion = firstSheetOf("mergedRegionWithTwoRegions.xlsx"); sheetWithMergedRegionsAltText = firstSheetOf("mergedRegionWithAltText.xlsx"); } @@ -77,6 +79,13 @@ public void descriptionAltRegion() { assertThat(description.toString(), is("\"A2:E2\" as a merged region(s) in sheet \"Sheet1\"")); } + @Test + public void descriptionMultipleMismatches() { + Description description = new StringDescription(); + hasSameMergedRegions(sheetWithTwoMergedRegion).describeTo(description); + assertThat(description.toString(), is("\"A2:E2, A4:E4\" as a merged region(s) in sheet \"Sheet1\"")); + } + @Test public void mismatch() { Description description = new StringDescription();