How do you list the most complex methods of a project in Sonar? - sonarqube

In Sonar, you can have the list of classes sorted by average complexity of methods of the class (when you list the complexity per method from the dashboard)
But how do you list the most complex methods project-wide ?

You can't do that, because Sonar does not keep measures at method level.

You can do that with our tool, called SourceMeter (by FrontEndART) which has a plug-in for Sonar as well. You can take a look at the online demo interface of SourceMeter.

Related

How to generate/pass default sorting explicity in panache query?

There are listAll(Sort s) -like methods in PanacheEntity. Suppose I don't want to build if statements for all cases (I also need page limits and etc), but wish to compute s as if it was omitted.
Is it possible?
How to generate "default" sorting instance of Sort? I don't see appropriate construction methods.
It's not possible at the moment, there is an enhancement request on the Quarkus Github repository, you can watch the issue and provides feedback on it: https://github.com/quarkusio/quarkus/issues/6439

Where to place the code for retrieving filtered data?

I need to implement functionality to search booking slot availability
by location, service, provider, and various combinations of these.
These will require a few queries and a lot of if / else conditions
Where should this code go?
Model
Classes Interface and Implementation
Should there be a single or multiple implementations
Is it helpful to use service provider in this case?
Repositories
Also, various controllers' methods will be dependant on this availability result.
Please suggest me the best way to handle this? Any details or a roadmap will be very helpful.
A repository is the best place to write your DB interaction code but if you are having the same filters on multiple models or repositories you can make one base repo and use it in your own repository. that's your first solution.
second thing, you can make a class for advanced queries. that is shown in the below-mentioned link you can check, it's also a good way to make your code clear and simple.
https://m.dotdev.co/writing-advanced-eloquent-search-query-filters-de8b6c2598db

AutoIT Page/Window Object Model

I would like to ask if we can also achieved a Page/Window Object Model in AutoIT? Majority of my project assignment was on Web Automation and I'm using Selenium Webdriver with Framework uses Page Object Model. Currently, I'm assigned to a project for GUI automation. I like to implement this kind of approach also in AutoIT if feasible so that I can reuse the objects to other classes. We are planning to use AutoIT standalone. I noticed that most of the example available in the internet was the object created on each class/script.
Your insights are highly appreciated.
Thanks!
General:
That common approach of using the Page Object Model (POM) Design Pattern isn't quit good feasible with AutoIt. Of course you can create a object structure with AutoIt too, but it was not intended for the language. Anyway, some of the goals of POM can be achieved with the following example suggestion of a test structure.
Please notice:
Since you don't provide enough information about your application under test (AUT), I explain a basic structure. The implementation depends on your application (SWING/RCP, WinForm etc.). It's also important which tool support do you need for your page object recognition. Besides WinForm that could be controled by ControlCommand functions in AutoIt, it's a proper way to use UIASpy or au3_uiautomation as helper tools.
UIASpy - UI Automation Spy Tool
au3_uiautomation
It's an advantage to know the POM structure in context with Selenium. I usually include a test case description with behavior driven development BDD (Gherkin syntax with Cucumber or SpecFlow), but this will not be a part of that example here.
Example structure:
The structure consists of two applications under test Calc and VlcPlayer. Both follow the common structure PageObjects and Tests. You should try to devide your page objects (files) in many subfolders to keep an overview. This substructure should be similar for the Tests folder/subfolders.
In the Tests area you could include several test stages or test categories depending on your test goals (Acceptance/UI tests, just functional smoke tests and so on). It's also a good idea to control the execution order by an separat wrapper file, TestCaseExecutionOrder.au3. This should exist for all test categories to avoid a mixing of them.
This wrapper au3 file contains the function calls, it's the processing start/control.
Approach description:
TestCaseExecutionOrder.au3
Calls the functions which are the test cases in the subfolders (Menu, PlaylistContentArea, SideNavigation).
Test case NiceName consists of some test steps.
These test steps have to be included into that script/file by:
#include-once ; this line is optional
#include "Menu\OpenFolder.au3"
Test step OpenFolder.au3 (which is a part of a test case) contains the function(s) to do the folder loading and there content.
In that functions the PageObject MenuItemMedia.au3 will be loaded/included into the script/file by:
#include-once ; this line is optional
#include "..\..\..\PageObjects\Menu\MenuItemMedia.au3"
File MenuItemMedia.au3 should only contain the recognition mechanism for that area and actions.
This could be find menu item Media (as a function).
or find open folder menu item (as a function) and so on.
Func _findMenuItemMedia()
; do the recognition action
; ...
Return $oMenuItem
EndFunc
In the test step OpenFolder.au3 which calls _findMenuItemMedia() like:
Global $oMedia = _findMenuItemMedia()
can a .click executed or something like .getText etc.
The test cases should only #include the files which are necessary (test steps). The test steps should also only #include the necessary files (page objects) and so on. So it's possible to adjust the recognition functions once and it can be used in the corresponding test steps.
Conclusion:
Of course it's hard to explain it in this way, but with this approach you can do a similar way like in Selenium for web testing. Please notice that you properbly have to use Global variables often. You have to be ensure the correct includings and don't lose the overview of your test, which is in OOP test based approaches much easier.
I recommend the usage of VS Code, because you can jump from file to file at the #include statements. That's pretty handy.
I hope this will help you.

How much rework do i have to do when moving from simple automation to Page Object Model framework using Cucumber and Selenium/Capybara?

My Goal is to create a Page Object Model Automation framework using Cucumber with capybara/selenium for mu client project. Currently my knowledge related to Page Object Model gem is very limited and at the same time i want to show some delivery by creating automation scripts using cucumber and capybara. So i am in the process of creating some feature files and subsequent step definitions.
So my question is, If i move to simple automation to POM framework, how much rework i have to do in terms of scripts and also if this approach is correct. Please guide me as i am pretty new to ruby automation.
Well this can be a very opinionated question, but I'll try to keep it simple:
If you already have well structured and modularised code (cucumber features and step defs), it won't take significant changes to move to POM. Its essentially a different structuring technique to keep your code organised and keep your changes minimal/confined.
Gems like siteprism can help you with creating well structured page objects, if you are open to learn an additional DSL (for siteprism) on top of cucumber / capybara. Or you can roll out your own without any additional libraries, though it would demand a thorough understanding of POM architecture and best practices.
Hope that helps.
I believe you will have a little work to migrate and meet increasingly the tool, the Framework POM only shows speed gain when you have some pages that already are mapped, it might take some time to be shown in reports, but I believe it has much to gain, organization, clarity and speed are some of the advantages of migration.
In my work I help other QAs learning and use POM in one day, a lot of guys use xpath to find objects, I just show how they can reuse that xpaths in a page object.
The second step I show to use method, not only elements, then they can reuse a lot of code and stop repeat steps, find where they break and use a simple method in siteprism page, example:
element :field_login , :xpath, "login"
element :field_password, :xpath, "password"
element :login_button, :xpath, "login_button"
def authenticate (username, password)
field_login.set username
field.password.set password
LoginPage.new if login_button.click
end
My next step is show to leave to use xpath and use css elements.
And after some sprints, they understand the beneficts of the framework, and it is default for all automation, include the DEVs can understand and help in tests now.
Warning this answer is somewhat controversial.
I'd say don't bother using the Page Object Model, its fundamentally flawed. The web is about resources and representations (REST) not about pages. BDD is about behaviour, not pages.
The danger with POM (particularly when you are not experienced) is that you write lots of scenarios to test what is on each page. When really what you should be doing is writing scenarios that confirm that some behaviour exists.

How to sort fields and methods in source code documents?

In many programming languages, fields and methods can be arranged freely, but the order impacts the readabilty of the code. Which ordering strategy do you apply?
Background: We (a group of researchers from the University of Trier) already looked at the code of different open source projects and tried to figure out what strategies are applied. But as you can imagine, it is hard to extract this information from the code. Now, we are interested in the concrete strategies you apply and want to share and discuss this information here. Please find further information on our project page.
private fields first
public fields (if any)
properties (if any, e.g. in C#) or simple Getter/Setter
constructors
public methods
private methods near to their appearance in public methods (in functional programming languages even inside public methods if possible)
Moreover I try to order each of these sections semantically or to their importance for the class. I really try to structure my code so that I can quickly gain an overview of everything important. However in very big classes I have my problems to follow my strategy and then I often use the outliner to get to fields or methods instead of looking for them by scrolling.

Resources