Commits

Brett Giles  committed fac9a21

Fixed issue with simplecov not working on cucumber. Now at 99% test coverage.

Need to add a couple of tests regarding depth and call multiplier, but discovered the emulator is not working quite as expected. Even when I reset the default call depth to 1 in the haskell code, the emulator seems to perform at least 10 calls. Need to track this down and then write a couple of cucumber tests to spin those elements.

  • Participants
  • Parent commits 2b64c73

Comments (0)

Files changed (16)

File Emulator/src/QServer/QServer.lhs

 
 
 defaultCallDepth :: Int
-defaultCallDepth = 1000
+defaultCallDepth = 1
 
 
 

File GUI/spec/controller/lqpl_controller_spec.rb

     it "should send 'set_data_from_lqpl_model' to sub1 and not to sub2" do
       @l.trim_button_action_performed
     end
-  end
+  end 
   
   # describe "file_compile_action_performed" do
   #     it "should setup the model messages" do

File GUI/src/com/drogar/lqpl/about/AboutDialog.java

     private JLabel aboutDataLabel;
 
     public AboutDialog() {
+        setTitle("About LQPL");
         setContentPane(contentPane);
         setModal(true);
         getRootPane().setDefaultButton(buttonOK);

File GUI/src/config/platform.rb

 
 
 def not_on_mac
-  yield if  !(RbConfig::CONFIG["host_os"] =~ /darwin/i)
+  testing = java.lang.System.get_property("com.drogar.testing.fest")
+  yield if  (!(RbConfig::CONFIG["host_os"] =~ /darwin/i)) || (testing && testing == "true")
 end
 #:nocov: 
 on_mac do

File GUI/src/lqpl/lqpl_controller.rb

       Application.application.quit_handler = ExitHandler.instance
     end
   
-  #:nocov:
     not_on_mac do
       { "the_menu.file_exit" => "file_exit",
         "the_menu.help_about" => "help_about"}.each do |k,v|
           add_listener :type => :action, :components => {k => v}
       end
     end
-    #:nocov:
   end
       
   set_file_menu_actions
   end
 
   def help_about_action_performed
-    AboutController.instance.open
+    AboutController.instance.handle_about
   end
 
   def file_compile_action_performed
   end
   
   def file_simulate_action_performed
-
     SimulateResultsController.instance.set_simulate_results(model.recursion_spinner,StackTranslationController.instance.get_stack_translation)
     SimulateResultsController.instance.open
   end

File GUI/src/panels/quantum_stack/descriptor/abstract_descriptor_painter.rb

   end
   
   def paint_value(g,center)
-    draw_text_centered_at_point(g,"#{@model_element.value}",Point.new(center.x, center.y+node_size)) 
+    draw_text_centered_at_point(g,"#{@model_element.value}",Point.new(center.x, center.y+2*node_size)) 
   end
   
   alias :paint_model_at_point :paintModelAtPoint

File GUI/testdata/qplprograms/level_four.qpl

+
+one_to_8::( ; c:Int) =
+{  q = |0>;
+   Had q;
+   measure q of
+     |0> => {c = one_to_4()}
+     |1> => {c = five_to_8()}
+}
+
+one_to_4::( ; c:Int) =
+{  q = |0>;
+   Had q;
+   measure q of
+     |0> => {c = one_to_2()}
+     |1> => {c = three_to_4()}
+}
+
+one_to_2::( ; c:Int) =
+{  q = |0>;
+   Had q;
+   measure q of
+     |0> => {c = 1}
+     |1> => {c = 2}
+}
+
+three_to_4::( ; c:Int) =
+{  q = |0>;
+   Had q;
+   measure q of
+     |0> => {c = 3}
+     |1> => {c = 4}
+}
+five_to_8::( ; c:Int) =
+{  q = |0>;
+   Had q;
+   measure q of
+     |0> => {c = five_to_6()}
+     |1> => {c = seven_to_8()}
+}
+five_to_6::( ; c:Int) =
+{  q = |0>;
+   Had q;
+   measure q of
+     |0> => {c = 5}
+     |1> => {c = 6}
+}
+seven_to_8::( ; c:Int) =
+{  q = |0>;
+   Had q;
+   measure q of
+     |0> => {c = 7}
+     |1> => {c = 8}
+}
+main::() =
+{  a = one_to_8()}

File GUI/testdata/qplprograms/recurse.qpl

+
+one_to_2::( ; c:Int) =
+{  q = |0>;
+   Had q;
+   measure q of
+     |0> => {c = 1}
+     |1> => {c = one_to_2()}
+}
+
+main::() =
+{  a = one_to_2()}

File README.testing

 
 In the JRuby portion of this, we use FEST for testing of the swing components, Cucumber
 to run "acceptance" tests and rspec to run unit tests. In each of those, we use ruby's
-'simplecov' gem to determine test coverage. However, there are a few issues with these
+'simplecov' gem to determine test coverage. However, there are a few notes regarding these
 combinations:
 
- - With Cucumber, FEST and simplecov, the coverage analysis is incomplete. Only the static
-   portions of the code are recorded. Accordingly, even though many items are actually exercised
-   (e.g., the opening of file dialogs in lqpl_controller), they are not recorded.
+ - Cucumber and FEST is the only way to test Swing related code. FEST testing just does not
+   seem to work in RSPEC. Note that for Cucumber coverage to be complete, we must call 
+   "LqplController.instance.open" to start the app, rather than using the java main. This
+   is due to the java main starting JRuby in a new process (without simplecov).
 
  - With rspec, FEST and simplecov, the coverage analysis is complete, but FEST will not drive
    any items that are opened. Hence, we can not add unit tests for methods such as the opening
  - Some items are only run on Windows or Linux computers - testing is intended to be run on 
    a Mac, therefore these are surrounded with :nocov: tags to remove them from the stats.
 
-Due to the first two points here, the coverage goal for the project GUI will only be 90%.
+Ignoring nocov tags, the coverage goal for the project GUI will be 97.5%, with no file being less
+than 95%. These are not added as part of the configuration of simplecov as this is an additive
+requirement. Either rspec or cucumber may be below this minimum provided the total is above.
 
 
 In the Haskell portions, the system was completely written prior to embracing a test driven

File features/cancel_dialogs.feature

+Feature: we can cancel the compile and open dialogs
+  As we may have selected the wrong dialog, we need to be able to cancel them.
+
+  Scenario: I cancel compiling a program
+    Given I select "Compile" from the "File" menu
+    And I cancel the dialog
+    Then the messages field should contain:
+      |partial|
+      |Compile action cancelled|
+
+
+  Scenario: I cancel loading a program
+    Given I select "Load" from the "File" menu
+    And I cancel the dialog
+    Then the messages field should contain:
+      |partial|
+      |QPO file load cancelled|
+

File features/compile_an_lqpl_program.feature

   As a researcher
   I want the program allow me to choose a "*.qpl" program and create a corresponding "*.qpo" file
   so I can start experimenting with LQPL
-
-	@wip
+  
   Scenario: I compile a simple qpl program
     Given I select "Compile" from the "File" menu
     And I load "coin.qpl" from the project directory "GUI/testdata/qplprograms"

File features/show_about_dialog.feature

+Feature: We can see a dialog with the version and a link to the website
+  As a researcher
+  I want the program to identify itself
+
+  Scenario:
+    Given I select "About" from the "Help" menu
+    Then the dialog "About LQPL" should have one of the following in its only label:
+           |result|
+           |Brett Giles|
+           |Robin|

File features/show_simulate_results.feature

     When I select "Load" from the "File" menu
     And I load "coin.reference.qpo" from the project directory "GUI/testdata/qplprograms"
 
-	@wip
   Scenario:
     When I click the button "Go" 1 time on the frame "Quantum Emulator"
     Given I select "Simulate" from the "File" menu

File features/step_definitions/cancel_dialogs.rb

+And /^I cancel the dialog$/ do 
+  fc = JFileChooserFixture.new($robot) #   $qe_frame.file_chooser()
+
+  fc.cancel
+
+end

File features/step_definitions/show_simulate_results.rb

 Then /^the dialog "([\w\s]*)" should have one of:$/ do |dialog_title, message_text_table|
   # table is a Cucumber::Ast::Table
   dialog_fixture = WindowFinder.find_dialog(DialogMatcher.with_title (dialog_title)).using($robot)
-  the_display_area_label = dialog_fixture.label(label_matcher_with_pattern("<html>.*html>"))
+  the_display_area_label = dialog_fixture.label(label_matcher_with_pattern("<html>.*"))
+  
+  any_text_is_in_text_component(message_text_table, the_display_area_label).should be_true
+  
+  dialog_fixture.button().click
+end
+
+Then /^the dialog "([\w\s]*)" should have one of the following in its only label:$/ do |dialog_title, message_text_table|
+  # table is a Cucumber::Ast::Table
+  dialog_fixture = WindowFinder.find_dialog(DialogMatcher.with_title (dialog_title)).using($robot)
+  the_display_area_label = dialog_fixture.label
   
   any_text_is_in_text_component(message_text_table, the_display_area_label).should be_true
   

File features/support/env.rb

   # FEST will call this method for us before the test.
   #
   def executeInEDT
-    com.drogar.lqpl.Main.main([])
+    LqplController.instance.open #com.drogar.lqpl.Main.main([])
   end
 end