<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Khaja Moinuddin Mohammed</title>
    <description>The latest articles on Forem by Khaja Moinuddin Mohammed (@moinuddin14).</description>
    <link>https://forem.com/moinuddin14</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F105108%2Fc3f78e8e-b9f7-42eb-a0ed-e265fc471726.png</url>
      <title>Forem: Khaja Moinuddin Mohammed</title>
      <link>https://forem.com/moinuddin14</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/moinuddin14"/>
    <language>en</language>
    <item>
      <title>DTD in Testng.xml file</title>
      <dc:creator>Khaja Moinuddin Mohammed</dc:creator>
      <pubDate>Thu, 03 Jun 2021 02:38:32 +0000</pubDate>
      <link>https://forem.com/moinuddin14/dtd-in-testng-xml-file-3lgp</link>
      <guid>https://forem.com/moinuddin14/dtd-in-testng-xml-file-3lgp</guid>
      <description>&lt;h3&gt;
  
  
  DTD stands for "Document Type Definition".
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;We say an xml is "Well Formed", if just the syntax of the xml is correct. But, let's assume you are providing a tool/framework and want users to use it in an opinionated way for easy consumption of your library, especially the xml file that the users have to create to use your tool/framework. You need to have, kind of schema, that you want users to follow, that is where DTD comes handy by providing both "Well Formed" and "Valid" xml&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Since, we are talking about testng (which is a Testing framework and stands for Test Next Generation), let's take a simple tetng.xml as below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UFT-8"?&amp;gt;
&amp;lt;!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd" &amp;gt;

&amp;lt;suite name="Suite1" verbose="1" &amp;gt;
  &amp;lt;test name="Nopackage" &amp;gt;
    &amp;lt;classes&amp;gt;
       &amp;lt;class name="NoPackageTest" /&amp;gt;
    &amp;lt;/classes&amp;gt;
  &amp;lt;/test&amp;gt;

  &amp;lt;test name="Regression1"&amp;gt;
    &amp;lt;classes&amp;gt;
      &amp;lt;class name="test.sample.ParameterSample"/&amp;gt;
      &amp;lt;class name="test.sample.ParameterTest"/&amp;gt;
    &amp;lt;/classes&amp;gt;
  &amp;lt;/test&amp;gt;
&amp;lt;/suite&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first line represents what xml version and encoding type we want our testng.xml to be compatible with. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Suite in Testng is represented by  tag, and can have multiple attributes passed. It can contain one or more tests, here we have two tests.&lt;/li&gt;
&lt;li&gt;Test tag in Testng is represented by  and can contain one or more TestNG classes.&lt;/li&gt;
&lt;li&gt;Classes is a Testng tag represented by  and holds a list of  objects&lt;/li&gt;
&lt;li&gt;Class of Testng is a Java class that contains at least one TestNG annotation and is represented by the  tag and can contain one or more test methods.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, comes the most important part, as per the subject of discussion of this post i.e., &lt;code&gt;DTD&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;All the xml tags that we have seen above are guided by the principles defined in the &lt;a href="//testng-1.0.dtd.html"&gt;Testng DTD&lt;/a&gt; file. &lt;/p&gt;

&lt;p&gt;Note: It's hard to read the html file, so use a &lt;a href="https://jsonformatter.org/html-viewer"&gt;Html viewer&lt;/a&gt; to read through the DTD file&lt;/p&gt;

&lt;p&gt;As part of this blog post, let's cover the small part from the original Testng's DTD file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- A suite is the top-level element of a testng.xml file                  --&amp;gt;

&amp;lt;!ELEMENT suite (listeners|packages|test|parameter|method-selectors|suite-files)* &amp;gt;

&amp;lt;!-- Attributes: --&amp;gt;
&amp;lt;!--
@attr  name        The name of this suite (as it will appear in the reports)
@attr  junit       Whether to run in JUnit mode.
@attr  verbose     How verbose the output on the console will be.  
                This setting has no impact on the HTML reports.
@attr  parallel   Whether TestNG should use different threads
                to run your tests (might speed up the process)
@attr  configfailurepolicy  Whether to continue attempting Before/After
                Class/Methods after they've failed once or just skip remaining.
@attr  thread-count An integer giving the size of the thread pool to use
                if you set parallel.
@attr  annotations  If "javadoc", TestNG will look for
                JavaDoc annotations in your sources, otherwise it will
                use JDK5 annotations.
@attr  time-out     The time to wait in milliseconds before aborting the
                method (if parallel="methods" ) or the test (parallel="tests")
@attr  skipfailedinvocationCounts Whether to skip failed invocations.
@attr  data-provider-thread-count An integer giving the size of the thread pool to use
       for parallel data providers.
@attr  object-factory A class that implements IObjectFactory that will be used to
       instantiate the test objects.
--&amp;gt;
&amp;lt;!ATTLIST suite 
    name CDATA #REQUIRED
    junit (true | false) "false"
    verbose CDATA #IMPLIED
    parallel (false | methods | tests | classes) "false"
    configfailurepolicy (skip | continue) "skip"
    thread-count CDATA "5"
    annotations CDATA #IMPLIED
    time-out CDATA #IMPLIED
    skipfailedinvocationCounts (true | false) "false"
    data-provider-thread-count CDATA "10"
    object-factory CDATA #IMPLIED
&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;We define xml comments between &lt;code&gt;&amp;lt;!--&lt;/code&gt; and &lt;code&gt;--&amp;gt;&lt;/code&gt; &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The tag &lt;code&gt;&amp;lt;!ELEMENT suite (listeners|packages|test|parameter|method-selectors|suite-files)* &amp;gt;&lt;/code&gt; Defines that the &lt;code&gt;suite&lt;/code&gt; element must contain one or all of the elements i.e., listeners, packages etc., Let's look at another example - &lt;code&gt;&amp;lt;!ELEMENT test (method-selectors?,parameter*,groups?,packages?,classes?) &amp;gt;&lt;/code&gt;, in this case the element &lt;code&gt;test&lt;/code&gt; can contain one or more of the mentioned elements i.e., method-selectors, parameter (or parameters), groups, packages and/or classes. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;@attr - Defines the attributes that can be passed onto the &lt;code&gt;suite&lt;/code&gt; tag. Let's see a couple of them. &lt;code&gt;@attr  name&lt;/code&gt; is an attribute with name and what is the data type it can hold is defined under &lt;code&gt;&amp;lt;!ATTLIST test &amp;gt;&lt;/code&gt; i.e., with &lt;code&gt;name CDATA #REQUIRED&lt;/code&gt; which defines that this is of type string through &lt;code&gt;CDATA&lt;/code&gt; and with &lt;code&gt;#REQUIRED&lt;/code&gt; we specify that this is a mandatory attribute, we can also have &lt;code&gt;#IMPLIED&lt;/code&gt; instead if the attribute isn't mandatory. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Let's look another example, &lt;code&gt;junit (true | false) "false"&lt;/code&gt; here we are specifying the attribute as junit and it can have a value of either true (or) false, with default value as false. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's it, you are now master at understanding any DTD, and most importantly you now know why you get weird errors when you don't include a DTD at the top of your xml document. &lt;/p&gt;

&lt;p&gt;If i missed anything or you want to see part 2 of this post on specific topics of DTD, do let me know in the comments. Thanks again for reading through this (not so very interesting ;) ) article. &lt;/p&gt;

&lt;p&gt;Resources: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/cbeust/testng/blob/master/core/src/main/java/testng-1.0.dtd.html"&gt;TestNg DTD&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.w3schools.com/xml/xml_dtd.asp"&gt;W3 Schools&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.liquid-technologies.com/DTD/Datatypes/CDATA.aspx"&gt;Liquid Technologies&lt;/a&gt;&lt;/p&gt;

</description>
      <category>testng</category>
      <category>dtd</category>
      <category>xml</category>
      <category>json</category>
    </item>
    <item>
      <title>What is your automation testing stack? </title>
      <dc:creator>Khaja Moinuddin Mohammed</dc:creator>
      <pubDate>Sat, 23 Nov 2019 10:16:21 +0000</pubDate>
      <link>https://forem.com/moinuddin14/what-is-automation-testing-stack-2066</link>
      <guid>https://forem.com/moinuddin14/what-is-automation-testing-stack-2066</guid>
      <description>&lt;p&gt;I am planning to put together the testing tools and frameworks into a spreadsheet with the help of the community members. &lt;/p&gt;

&lt;p&gt;Please let us know what’s the tech stack of your automation testing across all layers like UI, API, Contract Testing, Unit Testing, Security Testing, Performance/load testing, Usability Testing, CI/CD, Containerization, Test Reporting, Monitoring of APIs etc., in the comments below. &lt;/p&gt;

&lt;p&gt;Feel free to add if you have any other different testing done. &lt;/p&gt;

</description>
      <category>devops</category>
      <category>testing</category>
      <category>productivity</category>
      <category>selenium</category>
    </item>
  </channel>
</rss>
