pptx-test

Valentin K.,JavaPowerPointMS OfficetestingHamcrest

pptx-test

pptx-test

Great news )) If you need to validate your PowerPoint files in tests, there is a small and cool solution:

https://github.com/kozikoff/pptx-test (opens in a new tab)

How to use

import PPTX;
import org.junit.jupiter.api.Test;
 
import java.io.IOException;
 
import static PPTX.containsText;
import static org.hamcrest.MatcherAssert.assertThat;
 
public class ContainsTextTests {
 
    @Test
    void canAssertThatPptxContainsText() throws IOException {
        PPTX pptx = new PPTX(getClass().getClassLoader().getResource("TestPPTX.pptx"));
        assertThat(pptx, containsText("lacinia nisi. Ut ac dolor vitae odio"));
        assertThat(pptx, containsText("My pretty chart"));
        assertThat(pptx, containsText("37.12%"));
        assertThat(pptx, containsText("Beehive State (official), The Mormon State"));
    }
}

How to add to your project

Just copy jar-file into lib directory of your project and make import in IntelliJ IDEA (Project structure - Modules - Dependencies). If you use Gradle, please add the following dependency to build.gradle:

dependencies {
    testImplementation files('lib/pptx-test.jar')
}

© By Valentin Kozikov—Send me email