Commits

Anonymous committed b9ff283

Implemented test to verify that concordion camera can work in test suites. At the moment it's failing as it can't work in test suite properly.
Changed version to be 0.2 as it's still far from release.

Comments (0)

Files changed (13)

ConcordionCamera.ipr

   <component name="AntConfiguration">
     <defaultAnt bundledAnt="true" />
   </component>
+  <component name="CodeStyleSettingsManager">
+    <option name="PER_PROJECT_SETTINGS">
+      <value>
+        <ADDITIONAL_INDENT_OPTIONS fileType="feature">
+          <option name="INDENT_SIZE" value="2" />
+          <option name="CONTINUATION_INDENT_SIZE" value="8" />
+          <option name="TAB_SIZE" value="4" />
+          <option name="USE_TAB_CHARACTER" value="false" />
+          <option name="SMART_TABS" value="false" />
+          <option name="LABEL_INDENT_SIZE" value="0" />
+          <option name="LABEL_INDENT_ABSOLUTE" value="false" />
+          <option name="USE_RELATIVE_INDENTS" value="false" />
+        </ADDITIONAL_INDENT_OPTIONS>
+        <ADDITIONAL_INDENT_OPTIONS fileType="groovy">
+          <option name="INDENT_SIZE" value="4" />
+          <option name="CONTINUATION_INDENT_SIZE" value="8" />
+          <option name="TAB_SIZE" value="4" />
+          <option name="USE_TAB_CHARACTER" value="false" />
+          <option name="SMART_TABS" value="false" />
+          <option name="LABEL_INDENT_SIZE" value="0" />
+          <option name="LABEL_INDENT_ABSOLUTE" value="false" />
+          <option name="USE_RELATIVE_INDENTS" value="false" />
+        </ADDITIONAL_INDENT_OPTIONS>
+        <ADDITIONAL_INDENT_OPTIONS fileType="gsp">
+          <option name="INDENT_SIZE" value="4" />
+          <option name="CONTINUATION_INDENT_SIZE" value="8" />
+          <option name="TAB_SIZE" value="4" />
+          <option name="USE_TAB_CHARACTER" value="false" />
+          <option name="SMART_TABS" value="false" />
+          <option name="LABEL_INDENT_SIZE" value="0" />
+          <option name="LABEL_INDENT_ABSOLUTE" value="false" />
+          <option name="USE_RELATIVE_INDENTS" value="false" />
+        </ADDITIONAL_INDENT_OPTIONS>
+        <ADDITIONAL_INDENT_OPTIONS fileType="haml">
+          <option name="INDENT_SIZE" value="2" />
+          <option name="CONTINUATION_INDENT_SIZE" value="8" />
+          <option name="TAB_SIZE" value="4" />
+          <option name="USE_TAB_CHARACTER" value="false" />
+          <option name="SMART_TABS" value="false" />
+          <option name="LABEL_INDENT_SIZE" value="0" />
+          <option name="LABEL_INDENT_ABSOLUTE" value="false" />
+          <option name="USE_RELATIVE_INDENTS" value="false" />
+        </ADDITIONAL_INDENT_OPTIONS>
+        <ADDITIONAL_INDENT_OPTIONS fileType="java">
+          <option name="INDENT_SIZE" value="4" />
+          <option name="CONTINUATION_INDENT_SIZE" value="8" />
+          <option name="TAB_SIZE" value="4" />
+          <option name="USE_TAB_CHARACTER" value="false" />
+          <option name="SMART_TABS" value="false" />
+          <option name="LABEL_INDENT_SIZE" value="0" />
+          <option name="LABEL_INDENT_ABSOLUTE" value="false" />
+          <option name="USE_RELATIVE_INDENTS" value="false" />
+        </ADDITIONAL_INDENT_OPTIONS>
+        <ADDITIONAL_INDENT_OPTIONS fileType="js">
+          <option name="INDENT_SIZE" value="4" />
+          <option name="CONTINUATION_INDENT_SIZE" value="8" />
+          <option name="TAB_SIZE" value="4" />
+          <option name="USE_TAB_CHARACTER" value="false" />
+          <option name="SMART_TABS" value="false" />
+          <option name="LABEL_INDENT_SIZE" value="0" />
+          <option name="LABEL_INDENT_ABSOLUTE" value="false" />
+          <option name="USE_RELATIVE_INDENTS" value="false" />
+        </ADDITIONAL_INDENT_OPTIONS>
+        <ADDITIONAL_INDENT_OPTIONS fileType="jsp">
+          <option name="INDENT_SIZE" value="4" />
+          <option name="CONTINUATION_INDENT_SIZE" value="8" />
+          <option name="TAB_SIZE" value="4" />
+          <option name="USE_TAB_CHARACTER" value="false" />
+          <option name="SMART_TABS" value="false" />
+          <option name="LABEL_INDENT_SIZE" value="0" />
+          <option name="LABEL_INDENT_ABSOLUTE" value="false" />
+          <option name="USE_RELATIVE_INDENTS" value="false" />
+        </ADDITIONAL_INDENT_OPTIONS>
+        <ADDITIONAL_INDENT_OPTIONS fileType="rb">
+          <option name="INDENT_SIZE" value="2" />
+          <option name="CONTINUATION_INDENT_SIZE" value="4" />
+          <option name="TAB_SIZE" value="2" />
+          <option name="USE_TAB_CHARACTER" value="false" />
+          <option name="SMART_TABS" value="false" />
+          <option name="LABEL_INDENT_SIZE" value="0" />
+          <option name="LABEL_INDENT_ABSOLUTE" value="false" />
+          <option name="USE_RELATIVE_INDENTS" value="true" />
+        </ADDITIONAL_INDENT_OPTIONS>
+        <ADDITIONAL_INDENT_OPTIONS fileType="sass">
+          <option name="INDENT_SIZE" value="2" />
+          <option name="CONTINUATION_INDENT_SIZE" value="8" />
+          <option name="TAB_SIZE" value="4" />
+          <option name="USE_TAB_CHARACTER" value="false" />
+          <option name="SMART_TABS" value="false" />
+          <option name="LABEL_INDENT_SIZE" value="0" />
+          <option name="LABEL_INDENT_ABSOLUTE" value="false" />
+          <option name="USE_RELATIVE_INDENTS" value="false" />
+        </ADDITIONAL_INDENT_OPTIONS>
+        <ADDITIONAL_INDENT_OPTIONS fileType="sql">
+          <option name="INDENT_SIZE" value="2" />
+          <option name="CONTINUATION_INDENT_SIZE" value="8" />
+          <option name="TAB_SIZE" value="4" />
+          <option name="USE_TAB_CHARACTER" value="false" />
+          <option name="SMART_TABS" value="false" />
+          <option name="LABEL_INDENT_SIZE" value="0" />
+          <option name="LABEL_INDENT_ABSOLUTE" value="false" />
+          <option name="USE_RELATIVE_INDENTS" value="false" />
+        </ADDITIONAL_INDENT_OPTIONS>
+        <ADDITIONAL_INDENT_OPTIONS fileType="xml">
+          <option name="INDENT_SIZE" value="4" />
+          <option name="CONTINUATION_INDENT_SIZE" value="8" />
+          <option name="TAB_SIZE" value="4" />
+          <option name="USE_TAB_CHARACTER" value="false" />
+          <option name="SMART_TABS" value="false" />
+          <option name="LABEL_INDENT_SIZE" value="0" />
+          <option name="LABEL_INDENT_ABSOLUTE" value="false" />
+          <option name="USE_RELATIVE_INDENTS" value="false" />
+        </ADDITIONAL_INDENT_OPTIONS>
+        <ADDITIONAL_INDENT_OPTIONS fileType="yml">
+          <option name="INDENT_SIZE" value="2" />
+          <option name="CONTINUATION_INDENT_SIZE" value="8" />
+          <option name="TAB_SIZE" value="4" />
+          <option name="USE_TAB_CHARACTER" value="false" />
+          <option name="SMART_TABS" value="false" />
+          <option name="LABEL_INDENT_SIZE" value="0" />
+          <option name="LABEL_INDENT_ABSOLUTE" value="false" />
+          <option name="USE_RELATIVE_INDENTS" value="false" />
+        </ADDITIONAL_INDENT_OPTIONS>
+      </value>
+    </option>
+  </component>
   <component name="CompilerConfiguration">
     <option name="DEFAULT_COMPILER" value="Javac" />
     <resourceExtensions />
     <entry_points version="2.0" />
   </component>
   <component name="IdProvider" IDEtalkID="295778741BDB592FC9A9DCE8E06F84A2" />
+  <component name="InspectionProjectProfileManager">
+    <profiles>
+      <profile version="1.0" is_locked="false">
+        <option name="myName" value="Project Default" />
+        <option name="myLocal" value="false" />
+        <inspection_tool class="HtmlUnknownAttribute" enabled="true" level="WARNING" enabled_by_default="true">
+          <option name="myValues">
+            <value>
+              <list size="1">
+                <item index="0" class="java.lang.String" itemvalue="c:run" />
+              </list>
+            </value>
+          </option>
+          <option name="myCustomValuesEnabled" value="true" />
+        </inspection_tool>
+      </profile>
+    </profiles>
+    <option name="PROJECT_PROFILE" value="Project Default" />
+    <option name="USE_PROJECT_PROFILE" value="true" />
+    <version value="1.0" />
+  </component>
   <component name="JavacSettings">
     <option name="ADDITIONAL_OPTIONS_STRING" value="-target 1.5" />
   </component>
     <groupId>com.sqanta.concordioncamera</groupId>
     <artifactId>ConcordionCamera</artifactId>
     <name>Concordion Camera</name>
-    <version>1.0</version>
+    <version>0.2</version>
     <packaging>jar</packaging>
 
     <description>Concordion extension to record videos of tests</description>

src/main/java/com/sqanta/util/Helpers.java

 package com.sqanta.util;
 
+import com.sqanta.concordioncameraextension.ConcordionCameraExtension;
 import nu.xom.Element;
 import nu.xom.Elements;
 import org.apache.commons.io.FileUtils;
  */
 public class Helpers {
 
+    /**
+     * Install concordion camera extension
+     */
+    public static void installConcordionCameraExtension() {
+        System.setProperty("concordion.extensions", ConcordionCameraExtension.class.getName());
+    }
+
     public enum InsertMode {
         BEFORE, AFTER
     }
         }
         return body;
     }
+
+
 }

src/test/java/spec/sqanta/concordioncameraextension/BaseRecordVideoFixture.java

      * Install concordion camera extension
      */
     public void installExtension() {
-        System.setProperty("concordion.extensions", ConcordionCameraExtension.class.getName());
+        Helpers.installConcordionCameraExtension();
     }
 
     /**
 
     @AfterClass
     public static void RestoreConcordionSpecFromBackup() throws IOException {
+        //Restore specs which were modified after command injection
         Helpers.restoreSpec(RecordVideoInQuickTimeTest.class);
     }
 

src/test/java/spec/sqanta/concordioncameraextension/RecordVideoOfTestSuiteTest.java

+package spec.sqanta.concordioncameraextension;
+
+import com.sqanta.util.Helpers;
+import org.concordion.integration.junit4.ConcordionRunner;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import spec.sqanta.concordioncameraextension.sampletestsuite.SampleTestSuiteTest;
+
+import java.io.File;
+
+@RunWith(ConcordionRunner.class)
+public class RecordVideoOfTestSuiteTest {
+
+    @BeforeClass
+    public static void setUp() {
+        Helpers.deleteConcordionCameraVideoFiles(getTestSuiteClass());
+    }
+
+    /**
+     * Installs concordion camera extension
+     */
+    public void installExtension() {
+        Helpers.installConcordionCameraExtension();
+    }
+
+    /**
+     * Get concordion camera videos count
+     *
+     * @return videos count
+     * @throws Exception
+     */
+    public int getVideosCount() throws Exception {
+        return Helpers.getConcordionCameraVideoFiles(getTestSuiteClass()).length;
+    }
+
+
+    /**
+     * Returns class for sample test suite
+     * @return Class
+     */
+    private static Class getTestSuiteClass(){
+        return SampleTestSuiteTest.class;
+    }
+
+
+    /**
+     * Verifies that first found video file is of substantial size
+     *
+     * @return "not empty" or "empty" based on file size
+     */
+    public String verifyVideoFileNotEmpty() throws Exception {
+        File videoFile = Helpers.getConcordionCameraVideoFiles(getTestSuiteClass())[0];
+        long fileSize = videoFile.length() / 1024;
+
+        //Check that file size is > 400 Kb to make sure that video was recorded
+        if (fileSize > 400) {
+            return "not empty";
+        }
+
+        return "empty, video file size: " + fileSize + " Kb";
+    }
+
+
+    /**
+     * Verifies that first found video file contains test suite name in it's name
+     *
+     * @return "test suite name" in case of success or "test name is not in video file name" in case of failure
+     */
+    public String verifyTestSuiteNamePresentInVideoFileName() throws Exception {
+        String videoFileName = getVideoFileName();
+        if (videoFileName.contains(getTestSuiteName())) {
+            return "test suite name";
+        }
+        return "test suite name is not in video file name, actual file name: " + videoFileName;
+    }
+
+    /**
+     * Return name of current test suite
+     *
+     * @return String current test suite name
+     */
+    private String getTestSuiteName() {
+        String testSuiteClassName = getTestSuiteClass().getSimpleName();
+        //Delete last "Test" from class name to get test suite name
+        String testSuiteName = testSuiteClassName.substring(0, testSuiteClassName.lastIndexOf("Test"));
+        return testSuiteName;
+    }
+
+
+    /**
+     * Verifies that current date and time are present in video file name
+     *
+     * @return "date and time" in case of success or "date or time are not in video file name" in case of failure
+     */
+    public String verifyDateAndTimePresentInVideoFileName() throws Exception {
+        String videoFileName = getVideoFileName();
+        if (videoFileName.contains(Helpers.getTodaysDate())) {
+            return "date and time";
+        }
+        return "date or time are not in video file name, actual file name: " + videoFileName;
+    }
+
+
+    /**
+     * Verifies that video was embedded in test results file
+     *
+     * @return "embedded" in case of success or "not embedded" in case of failure
+     */
+    public String verifyVideoIsEmbeddedInTestResults() throws Exception {
+        String testResultsFile = Helpers.getConcordionTestResultsFileAsString(getTestSuiteClass(), getTestSuiteName()+".html");
+        if (testResultsFile.contains("<video src=\"" + getVideoFileName() + "\"")) {
+            return "embedded";
+        }
+
+        return "not embedded";
+    }
+
+
+    /**
+     * Retrieves name of first found video file
+     *
+     * @return file name
+     * @throws Exception if no video files found
+     */
+    private String getVideoFileName() throws Exception {
+        String videoFileName = Helpers.getConcordionCameraVideoFiles(getTestSuiteClass())[0].getName();
+        return videoFileName;
+    }
+
+
+}

src/test/java/spec/sqanta/concordioncameraextension/sampletestsuite/SampleTestOneTest.java

+package spec.sqanta.concordioncameraextension.sampletestsuite;
+
+import org.concordion.integration.junit4.ConcordionRunner;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import spec.sqanta.concordioncameraextension.BaseRecordVideoFixture;
+import spec.sqanta.concordioncameraextension.SimpleConcordionSpecTest;
+
+@RunWith(ConcordionRunner.class)
+public class SampleTestOneTest extends SimpleConcordionSpecTest{
+
+}

src/test/java/spec/sqanta/concordioncameraextension/sampletestsuite/SampleTestSuiteTest.java

+package spec.sqanta.concordioncameraextension.sampletestsuite;
+
+import org.concordion.integration.junit4.ConcordionRunner;
+import org.junit.runner.RunWith;
+
+@RunWith(ConcordionRunner.class)
+public class SampleTestSuiteTest {
+
+}

src/test/java/spec/sqanta/concordioncameraextension/sampletestsuite/SampleTestTwoTest.java

+package spec.sqanta.concordioncameraextension.sampletestsuite;
+
+import org.concordion.integration.junit4.ConcordionRunner;
+import org.junit.runner.RunWith;
+import spec.sqanta.concordioncameraextension.SimpleConcordionSpecTest;
+
+@RunWith(ConcordionRunner.class)
+public class SampleTestTwoTest extends SimpleConcordionSpecTest{
+
+}

src/test/resources/spec/sqanta/concordioncameraextension/ConcordionCameraExtension.html

 <p>
     This extension gives you ability to record video of test execution and display it on concordion test results
     page.<br/>
-    It adds new concordion command <code>concordionCamera="format"</code> where <code>format</code> specifies in which
-    format to record videos.
-    At the moment you can record video in <a c:run="concordion" href="RecordVideoInAVI.html">AVI</a> or <a
-        c:run="concordion" href="RecordVideoInQuickTime.html">QuickTime</a> format.
+    It adds new concordion command <code>concordionCamera="format"</code> where <code>format</code> specifies in which  format to record videos.
+    At the moment you can record video in <a c:run="concordion" href="RecordVideoInAVI.html">AVI</a> or <a c:run="concordion" href="RecordVideoInQuickTime.html">QuickTime</a> format.
+
+    You can also use Concordion Camera to <a c:run="concordion" href="RecordVideoOfTestSuite.html">record video of test suites</a>.
 </p>
 </body>
 </html>

src/test/resources/spec/sqanta/concordioncameraextension/RecordVideoOfTestSuite.html

+<html xmlns:c="http://www.concordion.org/2007/concordion" xmlns:cx="urn:concordion-extensions:2010">
+<link href="../../../concordion.css" rel="stylesheet" type="text/css"/>
+<body>
+<h3>Sample Test Suite</h3>
+
+<p>
+    Concordion Camera can be used in test suites to record video of test suite execution.
+    When camera is used in test suite it will override individual test camera commands.
+    Video recording will start at the beginning of test suite and finish when suite is finished.
+</p>
+
+<div class="example">
+    <p>
+        <b>Given</b> test suite with concordionCamera command in it's body and each of tests in test suite also contain concordion camera commands<br/>
+        <b>And</b> Concordion Camera extension is <span c:execute="installExtension()">installed</span><br/>
+        <b>When</b> <a c:run="concordion" href="sampletestsuite/SampleTestSuite.html">testSuite</a> is executed<br/>
+        <b>Then</b> just <span c:assertEquals="getVideosCount()">1</span> <span c:assertEquals="verifyVideoFileNotEmpty()">not empty</span> video file is recorded<br/>
+        <b>And</b> it has <span c:assertEquals="verifyTestSuiteNamePresentInVideoFileName()">test suite name</span>, <span c:assertEquals="verifyDateAndTimePresentInVideoFileName()">date and time</span> in file name<br/>
+        <b>And</b> video is <span c:assertEquals="verifyVideoIsEmbeddedInTestResults()">embedded</span> in test suite result report<br/>
+    </p>
+</div>
+
+</body>
+</html>

src/test/resources/spec/sqanta/concordioncameraextension/sampletestsuite/SampleTestOne.html

+<html xmlns:c="http://www.concordion.org/2007/concordion" xmlns:cx="urn:concordion-extensions:2010">
+<link href="../../../../concordion.css" rel="stylesheet" type="text/css"/>
+<body>
+<h1>Sample Concordion Spec One</h1>
+
+<p>
+    Just a dummy test with concordion camera command in it's body
+    <span cx:concordionCamera="avi"/>
+</p>
+
+<div class="example">
+    <p>Do something for <span c:execute="doSomething(#TEXT)">3</span> seconds</p>
+</div>
+
+</body>
+</html>

src/test/resources/spec/sqanta/concordioncameraextension/sampletestsuite/SampleTestSuite.html

+<html xmlns:c="http://www.concordion.org/2007/concordion" xmlns:cx="urn:concordion-extensions:2010">
+<link href="../../../../concordion.css" rel="stylesheet" type="text/css"/>
+<body>
+<h1>Sample Test Suite</h1>
+
+<span cx:concordionCamera="avi"/>
+
+<p>
+    Just sample test suite with concordionCamera command in it's body<br/>
+    And two tests: <a c:run="concordion" href="SampleTestOne.html">Sample Test One</a> and <a c:run="concordion" href="SampleTestTwo.html">Sample Test Two</a> with concordionCamera command in each of their bodies<br/>
+</p>
+
+</body>
+</html>

src/test/resources/spec/sqanta/concordioncameraextension/sampletestsuite/SampleTestTwo.html

+<html xmlns:c="http://www.concordion.org/2007/concordion" xmlns:cx="urn:concordion-extensions:2010">
+<link href="../../../../concordion.css" rel="stylesheet" type="text/css"/>
+<body>
+<h1>Sample Concordion Spec Two</h1>
+
+<p>
+    Just a dummy test with concordion camera command in it's body
+    <span cx:concordionCamera="avi"/>
+</p>
+
+<div class="example">
+    <p>Do something for <span c:execute="doSomething(#TEXT)">3</span> seconds</p>
+</div>
+
+</body>
+</html>