How to use HtmlTestDocsGenerator class of com.consol.citrus.docs package

Best Citrus code snippet using com.consol.citrus.docs.HtmlTestDocsGenerator

Source:CreateDocsMojo.java Github

copy

Full Screen

...14 * limitations under the License.15 */16package com.consol.citrus.mvn.plugin;17import com.consol.citrus.docs.ExcelTestDocsGenerator;18import com.consol.citrus.docs.HtmlTestDocsGenerator;19import com.consol.citrus.mvn.plugin.config.docs.ExcelDocConfiguration;20import com.consol.citrus.mvn.plugin.config.docs.HtmlDocConfiguration;21import org.apache.maven.plugin.MojoExecutionException;22import org.apache.maven.plugins.annotations.*;23import org.codehaus.plexus.components.interactivity.Prompter;24import org.codehaus.plexus.components.interactivity.PrompterException;25import java.util.Arrays;26import java.util.Optional;27/**28 * Creates test documentation in interactive mode. Either uses mode excel for MS Excel output or29 * html for HTML web page output.30 *31 * @author Christoph Deppisch32 * @since 2.7.433 */34@Mojo(name = "create-docs")35public class CreateDocsMojo extends AbstractCitrusMojo {36 @Parameter(property = "citrus.skip.create.docs", defaultValue = "false")37 protected boolean skipCreateDocs;38 @Component39 private Prompter prompter;40 private final ExcelTestDocsGenerator excelTestDocsGenerator;41 private final HtmlTestDocsGenerator htmlTestDocsGenerator;42 /**43 * Default constructor.44 */45 public CreateDocsMojo() {46 this(new ExcelTestDocsGenerator(), new HtmlTestDocsGenerator());47 }48 /**49 * Constructor using final fields.50 * @param excelTestDocsGenerator51 * @param htmlTestDocsGenerator52 */53 public CreateDocsMojo(ExcelTestDocsGenerator excelTestDocsGenerator, HtmlTestDocsGenerator htmlTestDocsGenerator) {54 this.excelTestDocsGenerator = excelTestDocsGenerator;55 this.htmlTestDocsGenerator = htmlTestDocsGenerator;56 }57 @Override58 public void doExecute() throws MojoExecutionException {59 if (skipCreateDocs) {60 return;61 }62 try {63 String mode = prompter.prompt("Choose documentation mode:", Arrays.asList("excel", "html"), "html");64 if (mode.equals("excel")) {65 createExcelDoc();66 } else if (mode.equals("html")) {67 createHtmlDoc();68 }69 } catch (PrompterException e) {70 getLog().info(e);71 }72 }73 /**74 * Create HTML documentation in interactive mode.75 * @throws PrompterException76 */77 private void createHtmlDoc() throws PrompterException {78 HtmlDocConfiguration configuration = new HtmlDocConfiguration();79 String heading = prompter.prompt("Enter overview title:", configuration.getHeading());80 String columns = prompter.prompt("Enter number of columns in overview:", configuration.getColumns());81 String pageTitle = prompter.prompt("Enter page title:", configuration.getPageTitle());82 String outputFile = prompter.prompt("Enter output file name:", configuration.getOutputFile());83 String logo = prompter.prompt("Enter file path to logo:", configuration.getLogo());84 String confirm = prompter.prompt("Confirm HTML documentation: outputFile='target/" + outputFile + (outputFile.endsWith(".html") ? "" : ".html") + "'\n",85 Arrays.asList("y", "n"), "y");86 if (confirm.equalsIgnoreCase("n")) {87 return;88 }89 HtmlTestDocsGenerator generator = getHtmlTestDocsGenerator();90 generator.withOutputFile(outputFile + (outputFile.endsWith(".html") ? "" : ".html"))91 .withPageTitle(pageTitle)92 .withOverviewTitle(heading)93 .withColumns(columns)94 .useSrcDirectory(getTestSrcDirectory())95 .withLogo(logo);96 generator.generateDoc();97 getLog().info("Successfully created HTML documentation: outputFile='target/" + outputFile + (outputFile.endsWith(".html") ? "" : ".html") + "'");98 }99 /**100 * Create Excel documentation in interactive mode.101 * @throws PrompterException102 */103 private void createExcelDoc() throws PrompterException {104 ExcelDocConfiguration configuration = new ExcelDocConfiguration();105 String company = prompter.prompt("Enter company:", configuration.getCompany());106 String author = prompter.prompt("Enter author:", configuration.getAuthor());107 String pageTitle = prompter.prompt("Enter page title:", configuration.getPageTitle());108 String outputFile = prompter.prompt("Enter output file name:", configuration.getOutputFile());109 String headers = prompter.prompt("Enter custom headers:", configuration.getHeaders());110 String confirm = prompter.prompt("Confirm Excel documentation: outputFile='target/" + outputFile + (outputFile.endsWith(".xls") ? "" : ".xls") + "'\n",111 Arrays.asList("y", "n"), "y");112 if (confirm.equalsIgnoreCase("n")) {113 return;114 }115 ExcelTestDocsGenerator generator = getExcelTestDocsGenerator();116 generator.withOutputFile(outputFile + (outputFile.endsWith(".xls") ? "" : ".xls"))117 .withPageTitle(pageTitle)118 .withAuthor(author)119 .withCompany(company)120 .useSrcDirectory(getTestSrcDirectory())121 .withCustomHeaders(headers);122 generator.generateDoc();123 getLog().info("Successfully created Excel documentation: outputFile='target/" + outputFile + (outputFile.endsWith(".xls") ? "" : ".xls") + "'");124 }125 /**126 * Gets the htmlTestDocsGenerator.127 *128 * @return129 */130 public HtmlTestDocsGenerator getHtmlTestDocsGenerator() {131 return Optional.ofNullable(htmlTestDocsGenerator).orElse(HtmlTestDocsGenerator.build());132 }133 /**134 * Gets the excelTestDocsGenerator.135 *136 * @return137 */138 public ExcelTestDocsGenerator getExcelTestDocsGenerator() {139 return Optional.ofNullable(excelTestDocsGenerator).orElse(ExcelTestDocsGenerator.build());140 }141 /**142 * Sets the prompter.143 * @param prompter the prompter to set144 */145 public void setPrompter(Prompter prompter) {...

Full Screen

Full Screen

Source:HtmlTestDocsGeneratorTest.java Github

copy

Full Screen

...25import java.io.IOException;26/**27 * @author Christoph Deppisch28 */29public class HtmlTestDocsGeneratorTest {30 @BeforeClass31 public void createSampleIT() {32 XmlTestGenerator generator = (XmlTestGenerator) new XmlTestGenerator()33 .withAuthor("Christoph")34 .withDescription("This is a sample test")35 .withName("SampleIT")36 .usePackage("com.consol.citrus.sample")37 .withFramework(UnitFramework.TESTNG);38 generator.create();39 }40 41 @Test42 public void testHtmlDocGeneration() throws IOException {43 HtmlTestDocsGenerator generator = HtmlTestDocsGenerator.build();44 generator.generateDoc();45 46 String docContent = FileUtils.readToString(new FileSystemResource(HtmlTestDocsGenerator.getOutputDirectory() + File.separator + generator.getOutputFile()));47 48 Assert.assertTrue(docContent.contains("<title>Citrus Test Documentation</title>"));49 Assert.assertTrue(docContent.contains("<img src=\"logo.png\" lowsrc=\"logo.png\" alt=\"Logo\"/>"));50 Assert.assertTrue(docContent.contains("<h1>Citrus Test Documentation</h1>"));51 Assert.assertTrue(docContent.contains(">Overview</th>"));52 Assert.assertTrue(docContent.contains("SampleIT.xml</a>"));53 Assert.assertTrue(docContent.contains(">Nr.</th>"));54 Assert.assertTrue(docContent.contains(">Test</th>"));55 Assert.assertTrue(docContent.contains("This is a sample test"));56 Assert.assertTrue(docContent.contains("src" + File.separator + "test" +57 File.separator + "resources" +58 File.separator + "com" + 59 File.separator + "consol" + 60 File.separator + "citrus" + 61 File.separator + "sample" +62 File.separator + "SampleIT.xml\">SampleIT.xml</a>"));63 }64 65 @Test66 public void testCustomizedHtmlDocGeneration() throws IOException {67 HtmlTestDocsGenerator generator = HtmlTestDocsGenerator.build()68 .withLogo("test-logo.png")69 .withOverviewTitle("CustomOverview")70 .withPageTitle("CustomPageTitle")71 .useSrcDirectory("src" + File.separator + "test" + File.separator);72 generator.generateDoc();73 74 String docContent = FileUtils.readToString(new FileSystemResource(HtmlTestDocsGenerator.getOutputDirectory() + File.separator + generator.getOutputFile()));75 76 Assert.assertTrue(docContent.contains("<title>CustomPageTitle</title>"));77 Assert.assertTrue(docContent.contains("<img src=\"test-logo.png\" lowsrc=\"test-logo.png\" alt=\"Logo\"/>"));78 Assert.assertTrue(docContent.contains("<h1>CustomPageTitle</h1>"));79 Assert.assertTrue(docContent.contains(">CustomOverview</th>"));80 Assert.assertTrue(docContent.contains("SampleIT.xml</a>"));81 Assert.assertTrue(docContent.contains(">Nr.</th>"));82 Assert.assertTrue(docContent.contains(">Test</th>"));83 Assert.assertTrue(docContent.contains("This is a sample test"));84 Assert.assertTrue(docContent.contains("src" + File.separator + "test" +85 File.separator + "resources" +86 File.separator + "com" + 87 File.separator + "consol" + 88 File.separator + "citrus" + ...

Full Screen

Full Screen

Source:GenerateDocsMojo.java Github

copy

Full Screen

...14 * limitations under the License.15 */16package com.consol.citrus.mvn.plugin;17import com.consol.citrus.docs.ExcelTestDocsGenerator;18import com.consol.citrus.docs.HtmlTestDocsGenerator;19import org.apache.maven.plugin.MojoExecutionException;20import org.apache.maven.plugins.annotations.*;21import java.util.Optional;22/**23 * Generates test overview documentation based on plugin configuration. Html documentation creates a web page that24 * contains a list of all available tests with meta information. Excel documentation creates a table of all available tests with25 * meta information such as name, author, status and so on.26 *27 * @author Christoph Deppisch28 * @since 2.7.429 */30@Mojo(name = "generate-docs", defaultPhase = LifecyclePhase.PROCESS_TEST_RESOURCES)31public class GenerateDocsMojo extends AbstractCitrusMojo {32 @Parameter(property = "citrus.skip.generate.docs", defaultValue = "false")33 protected boolean skipGenerateDocs;34 private final ExcelTestDocsGenerator excelTestDocGenerator;35 private final HtmlTestDocsGenerator htmlTestDocGenerator;36 /**37 * Default constructor.38 */39 public GenerateDocsMojo() {40 this(new ExcelTestDocsGenerator(), new HtmlTestDocsGenerator());41 }42 /**43 * Constructor using final fields.44 * @param excelTestDocGenerator45 * @param htmlTestDocGenerator46 */47 public GenerateDocsMojo(ExcelTestDocsGenerator excelTestDocGenerator, HtmlTestDocsGenerator htmlTestDocGenerator) {48 this.excelTestDocGenerator = excelTestDocGenerator;49 this.htmlTestDocGenerator = htmlTestDocGenerator;50 }51 @Override52 public void doExecute() throws MojoExecutionException {53 if (skipGenerateDocs) {54 return;55 }56 if (getDocs().getExcel() != null) {57 ExcelTestDocsGenerator generator = getExcelTestDocGenerator();58 generator.withOutputFile(getDocs().getExcel().getOutputFile() + (getDocs().getExcel().getOutputFile().endsWith(".xls") ? "" : ".xls"))59 .withPageTitle(getDocs().getExcel().getPageTitle())60 .withAuthor(getDocs().getExcel().getAuthor())61 .withCompany(getDocs().getExcel().getCompany())62 .useSrcDirectory(getTestSrcDirectory())63 .withCustomHeaders(getDocs().getExcel().getHeaders());64 generator.generateDoc();65 getLog().info("Successfully created Excel documentation: outputFile='target/" + getDocs().getExcel().getOutputFile() + (getDocs().getExcel().getOutputFile().endsWith(".xls") ? "" : ".xls") + "'");66 }67 if (getDocs().getHtml() != null) {68 HtmlTestDocsGenerator generator = getHtmlTestDocGenerator();69 generator.withOutputFile(getDocs().getHtml().getOutputFile() + (getDocs().getHtml().getOutputFile().endsWith(".html") ? "" : ".html"))70 .withPageTitle(getDocs().getHtml().getPageTitle())71 .withOverviewTitle(getDocs().getHtml().getHeading())72 .withColumns(getDocs().getHtml().getColumns())73 .useSrcDirectory(getTestSrcDirectory())74 .withLogo(getDocs().getHtml().getLogo());75 generator.generateDoc();76 getLog().info("Successfully created HTML documentation: outputFile='target/" + getDocs().getHtml().getOutputFile() + (getDocs().getHtml().getOutputFile().endsWith(".html") ? "" : ".html") + "'");77 }78 }79 /**80 * Gets the htmlTestDocGenerator.81 *82 * @return83 */84 public HtmlTestDocsGenerator getHtmlTestDocGenerator() {85 return Optional.ofNullable(htmlTestDocGenerator).orElse(HtmlTestDocsGenerator.build());86 }87 /**88 * Gets the excelTestDocGenerator.89 *90 * @return91 */92 public ExcelTestDocsGenerator getExcelTestDocGenerator() {93 return Optional.ofNullable(excelTestDocGenerator).orElse(ExcelTestDocsGenerator.build());94 }95}...

Full Screen

Full Screen

HtmlTestDocsGenerator

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.docs;2import com.consol.citrus.Citrus;3import com.consol.citrus.docs.html.HtmlTestDocsGenerator;4import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;5import org.testng.annotations.Test;6import java.io.File;7public class HtmlTestDocsGeneratorTest extends TestNGCitrusTestRunner {8 public void testHtmlTestDocsGenerator() {9 HtmlTestDocsGenerator generator = new HtmlTestDocsGenerator();10 generator.generate(new File("src/test/resources"), new File("target/test-docs"));11 }12}13package com.consol.citrus.docs;14import com.consol.citrus.Citrus;15import com.consol.citrus.docs.html.HtmlTestDocsGenerator;16import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;17import org.testng.annotations.Test;18import java.io.File;19public class HtmlTestDocsGeneratorTest extends TestNGCitrusTestRunner {20 public void testHtmlTestDocsGenerator() {21 HtmlTestDocsGenerator generator = new HtmlTestDocsGenerator();22 generator.generate(new File("src/test/resources"), new File("target/test-docs"));23 }24}25package com.consol.citrus.docs;26import com.consol.citrus.Citrus;27import com.consol.citrus.docs.html.HtmlTestDocsGenerator;28import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;29import org.testng.annotations.Test;30import java.io.File;31public class HtmlTestDocsGeneratorTest extends TestNGCitrusTestRunner {32 public void testHtmlTestDocsGenerator() {33 HtmlTestDocsGenerator generator = new HtmlTestDocsGenerator();34 generator.generate(new File("src/test/resources"), new File("target/test-docs"));35 }36}37package com.consol.citrus.docs;38import com.consol.citrus.Citrus;39import com.consol.citrus.docs.html.HtmlTestDocsGenerator;40import com.consol.citrus.dsl.testng.TestNGCitrusTest

Full Screen

Full Screen

HtmlTestDocsGenerator

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.docs;2import com.consol.citrus.dsl.testng.TestNGCitrusTest;3import org.testng.annotations.Test;4public class HtmlTestDocsGeneratorTest extends TestNGCitrusTest {5 public void generateTestDocs() {6 HtmlTestDocsGenerator generator = new HtmlTestDocsGenerator();7 generator.generate("target/test-docs", "com.consol.citrus");8 }9}10package com.consol.citrus.docs;11import com.consol.citrus.dsl.testng.TestNGCitrusTest;12import org.testng.annotations.Test;13public class HtmlTestDocsGeneratorTest extends TestNGCitrusTest {14 public void generateTestDocs() {15 HtmlTestDocsGenerator generator = new HtmlTestDocsGenerator();16 generator.generate("target/test-docs", "com.consol.citrus");17 }18}19package com.consol.citrus.docs;20import com.consol.citrus.dsl.testng.TestNGCitrusTest;21import org.testng.annotations.Test;22public class HtmlTestDocsGeneratorTest extends TestNGCitrusTest {23 public void generateTestDocs() {24 HtmlTestDocsGenerator generator = new HtmlTestDocsGenerator();25 generator.generate("target/test-docs", "com.consol.citrus");26 }27}28package com.consol.citrus.docs;29import com.consol.citrus.dsl.testng.TestNGCitrusTest;30import org.testng.annotations.Test;31public class HtmlTestDocsGeneratorTest extends TestNGCitrusTest {32 public void generateTestDocs() {33 HtmlTestDocsGenerator generator = new HtmlTestDocsGenerator();34 generator.generate("target/test-docs", "com.consol.citrus");35 }36}37package com.consol.citrus.docs;38import com.consol.citrus.dsl.testng.TestNGCitrusTest;39import org.testng.annotations.Test;

Full Screen

Full Screen

HtmlTestDocsGenerator

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.docs.HtmlTestDocsGenerator;2import com.consol.citrus.docs.TestDocGenerator;3public class 4 {4public static void main(String[] args) {5TestDocGenerator htmlTestDocsGenerator = new HtmlTestDocsGenerator();6htmlTestDocsGenerator.generate(getTestDocsDirectory());7}8private static String getTestDocsDirectory() {9String path = "C:/Users/.../testdocs";10return path;11}12}

Full Screen

Full Screen

HtmlTestDocsGenerator

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.docs;2import java.io.File;3import java.io.IOException;4import org.testng.annotations.Test;5import com.consol.citrus.docs.util.HtmlTestDocsGenerator;6public class TestDocsGeneratorTest {7public void testGenerator() throws IOException {8 HtmlTestDocsGenerator generator = new HtmlTestDocsGenerator();9 generator.generate(new File("src/test/resources/"), new File("target/test-docs"));10}11}

Full Screen

Full Screen

HtmlTestDocsGenerator

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.docs;2import java.io.File;3import java.io.IOException;4import java.util.ArrayList;5import java.util.List;6import org.springframework.core.io.ClassPathResource;7import org.springframework.core.io.Resource;8import org.springframework.util.FileCopyUtils;9public class HtmlTestDocsGenerator {10 public static void main(String[] args) throws IOException {11 TestDocsGenerator generator = new TestDocsGenerator();12 generator.setTestDirectory(new ClassPathResource("tests"));13 generator.generate();14 Resource indexHtml = new ClassPathResource("index.html");15 FileCopyUtils.copy(indexHtml.getFile(), new File("target/test-classes/index.html"));16 Resource styleCss = new ClassPathResource("style.css");17 FileCopyUtils.copy(styleCss.getFile(), new File("target/test-classes/style.css"));18 Resource jqueryJs = new ClassPathResource("jquery.js");19 FileCopyUtils.copy(jqueryJs.getFile(), new File("target/test-classes/jquery.js"));20 Resource jqueryTablesorterJs = new ClassPathResource("jquery.tablesorter.min.js");21 FileCopyUtils.copy(jqueryTablesorterJs.getFile(), new File("target/test-classes/jquery.tablesorter.min.js"));22 Resource jqueryTablesorterPagerJs = new ClassPathResource("jquery.tablesorter.pager.js");23 FileCopyUtils.copy(jqueryTablesorterPagerJs.getFile(), new File("target/test-classes/jquery.tablesorter.pager.js"));24 Resource jqueryTablesorterPagerCss = new ClassPathResource("jquery.tablesorter.pager.css");25 FileCopyUtils.copy(jqueryTablesorterPagerCss.getFile(), new File("target/test-classes/jquery.tablesorter.pager.css"));26 Resource jqueryTablesorterThemesBlueCss = new ClassPathResource("jquery.tablesorter.themes.blue.css");27 FileCopyUtils.copy(jqueryTablesorterThemesBlueCss.getFile(), new File("

Full Screen

Full Screen

HtmlTestDocsGenerator

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.docs.HtmlTestDocsGenerator;2public class 4 {3 public static void main(String[] args) {4 HtmlTestDocsGenerator.builder()5 .withBasePath("src/test/resources")6 .withTestSources("com.consol.citrus.samples")7 .withTestResults("target/test-reports")8 .withReportName("test-docs")9 .withReportTitle("Test Documentation")10 .withDescription("This is the test documentation generated by Citrus")11 .withAuthor("Citrus Team")12 .withVersion("1.0")13 .build()14 .generate();15 }16}17import com.consol.citrus.docs.HtmlTestDocsGenerator;18public class 5 {19 public static void main(String[] args) {20 HtmlTestDocsGenerator.builder()21 .withBasePath("src/test/resources")22 .withTestSources("com.consol.citrus.samples")23 .withTestResults("target/test-reports")24 .withReportName("test-docs")25 .withReportTitle("Test Documentation")26 .withDescription("This is the test documentation generated by Citrus")27 .withAuthor("Citrus Team")28 .withVersion("1.0")29 .build()30 .generate();31 }32}33import com.consol.citrus.docs.HtmlTestDocsGenerator;34public class 6 {35 public static void main(String[] args) {36 HtmlTestDocsGenerator.builder()37 .withBasePath("src/test/resources")38 .withTestSources("com.consol.citrus.samples")39 .withTestResults("target/test-reports")40 .withReportName("test-docs")41 .withReportTitle("Test Documentation")42 .withDescription("This is the test documentation generated by Citrus")43 .withAuthor("Citrus Team")44 .withVersion("1.0")45 .build()46 .generate();47 }48}49import

Full Screen

Full Screen

HtmlTestDocsGenerator

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.docs.HtmlTestDocsGenerator;2import com.consol.citrus.docs.TestDocsGenerator;3import com.consol.citrus.docs.model.TestDoc;4import com.consol.citrus.docs.model.TestDocGroup;5import com.consol.citrus.docs.model.TestDocGroupFactory;6import

Full Screen

Full Screen

HtmlTestDocsGenerator

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.docs.HtmlTestDocsGenerator;2public class 4 {3 public static void main(String[] args) {4 HtmlTestDocsGenerator htmlTestDocsGenerator = new HtmlTestDocsGenerator();5 htmlTestDocsGenerator.generateHtmlTestDocs("/home/user/MyProject/src/test/java/com/consol/citrus/samples", "test-docs");6 }7}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Citrus automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful