Commits

Kostya Marchenko committed b0074fa

Modified extension to work properly with test suites

Comments (0)

Files changed (3)

src/main/java/com/sqanta/concordioncameraextension/ConcordionCameraCommand.java

         Check.isFalse(commandCall.hasChildCommands(), "Nesting commands inside 'concordionCamera' is not supported");
 
         //Check if camera is already started
-        if(ConcordionCamera.started()){
+        if (ConcordionCamera.started()) {
             return;
         }
 
     /**
      * Generate video file name based on spec name, date and time
      *
-     * @return
+     * @return name of video file for current spec
      */
     private String getVideoFileName() {
-        String specPrefix = Helpers.getFilePrefix(resource.getName());
-        return Joiner.on("_").join(specPrefix, Helpers.getTodaysDateTime());
+        return Joiner.on("_").join(getSpecName(), Helpers.getTodaysDateTime());
+    }
+
+    /**
+     * Retrieves name of current specification
+     *
+     * @return specification name
+     */
+    private String getSpecName() {
+        return Helpers.getFilePrefix(resource.getName());
     }
 
 
     public void afterProcessingSpecification(SpecificationProcessingEvent specificationProcessingEvent) {
         //Stop camera after specification is executed
         try {
+            //Don't touch camera if it was started by different spec
+            if (!ConcordionCamera.getVideoFileName().contains(getSpecName())) {
+                return;
+            }
+
             ConcordionCamera.stopCamera();
+
         } catch (Exception e) {
             System.err.println(e.toString());
         }

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

 
 <p>
     Just a dummy test with concordion camera command in it's body
-    <span cx:concordionCamera="avi"/>
+    <span cx:concordionCamera="quicktime"/>
 </p>
 
 <div class="example">

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

 <body>
 <h1>Sample Test Suite</h1>
 
-<span cx:concordionCamera="avi"/>
+<span cx:concordionCamera="quicktime"/>
 
 <p>
     Just sample test suite with concordionCamera command in it's body<br/>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.