public RunResult run() throws IOException {
            if (inConfig == null) {
                throw new IllegalStateException("in config must be set");
            }
            if (outputPath == null) {
                throw new IllegalStateException("outputPath must be set");
            }

            String fileName = outputPath.getFileName().toString();
            if (!fileName.endsWith(".csv")) {
                throw new IllegalArgumentException("outputPath must end with .csv");
            }
            Path dir = outputPath.getParent().resolve(fileName.substring(0, fileName.length() - 4));

            Files.createDirectories(dir);

            // exec: config
            execConfig.set("min_output_tasks", 1);

            // out: config
            ConfigSource outConfig = newConfig()
                    .set("type", "file")
                    .set("path_prefix", dir.resolve("fragments_").toString())
                    .set("file_ext", "csv")
                    .set("formatter", newConfig()
                            .set("type", "csv")
                            .set("header_line", false)
                            .set("newline", "LF"));

            // combine exec:, out: and in:
            ConfigSource config = newConfig()
                    .set("exec", execConfig)
                    .set("in", inConfig)
                    .set("filters", filtersConfig)
                    .set("out", outConfig);

            // embed.run returns TestingBulkLoader.TestingExecutionResult because
            // LoaderState.buildExecuteResultWithWarningException is overridden.
            RunResult result = (RunResult) embed.run(config);

            return buildRunResultWithOutput(result, dir, outputPath);
        }
This method returns PreviewResult.

@return PreviewResult returns the result by PreviewExecutor
@throws IOException in case of failures in file operations
embulk-junit4/src/main/java/org/embulk/test/TestingEmbulk.java