Project

General

Profile

action #56786

Updated by riafarov over 4 years ago

## Description 
 I as a YaST developer want to write integration tests for the module 

 Based on the code implemented by Ladi: https://github.com/lslezak/cucumber-yast, after #56009 we already have a gem able to operate a few controls in the UI: 
 https://github.com/jknphy/libyui_client 

 Ladi provides with 3 suggestions. See (1)(2)(3) below.  
 We should also (4) format the code and (5) extend the library trying with other users controls. 

 1) the "it" describes a single test, each test should be independent (i.e. do not  
 depend on the result of any previous test). RSpec even supports randomizing the order 
 of the tests using the "rspec --order random" option, this can help to find the  
 dependencies between the tests. 

 Moreover rspec can optionally run only a specified test, not the whole file. Example:  
 "rspec spec/libyui_client_spec.rb:38", that will start the test at line 38, ignoring  
 the other tests. 

 So there should be one big: `it "writes the entered IP address to the /etc/hosts" do ...` 

 test which does all the steps inside. 

 We need to print the progress messages by yourselves, 
 We might use "rainbow" gem or similar to print the colored output (or maybe rspec provides some API) 


 2) The test is destructive, it really modifies the /etc/hosts on the machine. 
 That's OK when running it in a testing environment (like openQA) but it's not 
 acceptable if you want to run the same test on your machine during development. 

 Ideally there should be a way to run the read-only and the read/write tests 
 separately. E.g. the read-only tests would simply press "Abort" button in the 
 end to avoid writing the changes to the system. 

 Or we could pass the read/write mode via the environment and depending on that the  
 "write" part would be skipped or not, that would avoid duplicating the tests. 

 We definitely need a way to safely run the tests (at least some safe subset) during the development. 


 3) Use the "aruba" gem for testing the file content, file existence, 
 file permissions, command STDOUT or STDERR, etc... 

 We do not need to reinvent the wheel in  
 https://github.com/jknphy/libyui_client/blob/master/spec/libyui_client_spec.rb#L39 

 So far Lady has used aruba only from cucumber tests, but it seems it provides some 
 helpers also for rspec. 

 See https://relishapp.com/cucumber/aruba/v/0-11-0/docs/file/check-if-file-has-content 

 Or maybe there is some other rspec extension for that, but as this is a really common problem,  
 some library (gem) must already exist... 

 4) Format the code with rubocop. 
 5) Extend the library libray interacting with other controls. 

 ## Acceptance criteria 
 1. Code There is formatted with robocop 
 2. Checkbox, radiobuttons, textbox, table basic interaction (set/get) is implemented in the library 

 ## Suggestions 
 Check if can serialize objects from the json ruby gem which libyui-restapi sends, as provides easy to apply MVC in the end. use methods to operate on buttons

Back