Project

General

Profile

action #56756

Updated by JERiveraMoya 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) suggestions plus we need to format the code and (5) extend the library trying with other users controls. code. 

 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 Then you obviously need to print the progress messages by yourselves, 
 We you might use "rainbow" gem or similar to print the colored output (or output. 
 (Or maybe rspec provides some API) API for that I do not know.) 


 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 you 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 I do not know what would be best but 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 You 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 I have 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, I do not know, but I guess 
 as this is a really common problem,  
 some library (gem) must already exist... 

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

 rubocop 


 ## Acceptance criteria 
 1. There is ruby gem which provides easy to use methods to operate on buttons

Back