I have developed a maven project using DoFixture.
My JAVA code looks somewhat like this:
Package A
Class P extends DoFixture
Method X
Package A
Class Q extends DoFixture
Method X
Method Y
When I make a Fitnesse table for this, like,
! |A.Q|
| X |
| Y |
On running it, Fitnesse returns this exception-> method missing : AdotQ in class A.Q, but when I run,
! |A.P|
| X |
it runs fine.
Not able to understand why Fitnesse is reading AdotQ as a method when it is a class in my code.Please note, I have compiled the code using mvn install.
Related
I am able to execute WebUI feature file against single browser (Zalenium) using parallel runner and defined driver in karate-config.js. How can we execute WebUI feature file against multiple browsers (Zalenium) using parallel runner or distributed testing?
Use a Scenario Outline and the parallel runner. Karate will run each row of an Examples table in parallel. But you will have to move the driver config into the Feature.
Just add a parallel runner to this sample project and try: https://github.com/intuit/karate/tree/master/examples/ui-test
Scenario Outline: <type>
* def webUrlBase = karate.properties['web.url.base']
* configure driver = { type: '#(type)', showDriverLog: true }
* driver webUrlBase + '/page-01'
* match text('#placeholder') == 'Before'
* click('{}Click Me')
* match text('#placeholder') == 'After'
Examples:
| type |
| chrome |
| geckodriver |
There are other ways you can experiment with, here is another pattern when you have a normal Scenario in main.feature - which you can then call later from a Scenario Outline from a separate "special" feature - which is used only when you want to do this kind of parallel-ization of UI tests.
Scenario Outline: <config>
* configure driver = config
* call read('main.feature')
Examples:
| config! |
| { type: 'chromedriver' } |
| { type: 'geckodriver' } |
| { type: 'safaridriver' } |
EDIT - also see this answer: https://stackoverflow.com/a/62325328/143475
And for other ideas: https://stackoverflow.com/a/61685169/143475
EDIT - it is possible to re-use the same browser instance for all tests and the Karate CI regression test does this, which is worth studying for ideas: https://stackoverflow.com/a/66762430/143475
I'm working on a Spring Boot project built with Gradle and the main language is Kotlin.
In this project, there is one imported library (developed in Java) which, depending on the version I use, has 5 or 6 parameters in the constructor of a specific class I use.
For now, I switch between the versions manually by changing the version number in the build.gradle.kts file so my question would be : regardless of the version I use, how could my code work for all the versions ?
So, basically,
library-version1.jar => Class(6 parameters)
library-version2.jar => Class(5 parameters)
project with library-version1.jar or library-version2.jar imported => universal code to create instance of Class
P.S : may I add that I have to use those 2 versions of the library.
I found the solution for my initial question :
val yourVariable = YourClass::class.java
val constructor = yourVariable.constructors[0] //The class I use has only one constructor
val implementationVersion = yourVariable.`package`.implementationVersion
if (implementationVersion < "a specific version number") {
constructor.newInstance(6 parameters) as YourClass
} else {
constructor.newInstance(5 parameters) as YourClass
}
But now I have a follow-up question that you can find in the comments (I can still post it here though) :
In my build.gradle.kts file, I have this line in my dependencies :
dependencies {
implementation("myLibrary:1.0")
...
}
Obviously, I don't want to switch between myLibrary v1 and v2 manually. Just by changing the build.gradle.kts file, would it be possible to have :
build.gradle.kts -> appV1 (if myLibrary v1 used)
-> appV2 (if myLibrary v2 used)
?
I have this condition in my recipe:
install_action = (::Win32::Service.exists?(windows_service['name']) ? :configure : :create)
and a ChefSpec for that in spec file:
#1: not working
allow_any_instance_of(Win32::Service)
.to receive(:exists?)
.with(windows_service[:name])
.and_return(true)
#2: also not working
stub_command("::Win32::Service.exists?(#{windows_service[:name]})").and_return(true)
Could you please help to find out what have I missed in the ChefSpec test that is not working and mocking the return value.
Thanks
This should work:
allow(::Win32::Service).to receive(:exists?).with(windows_service[:name]).and_return(true)
Point is you stub a class method exists?, and not an instance method. That's why allow_any_instance_of does not work. And stub_command is actually for shell commands like stub_command('cat file | grep "hello"')
In Eclipse, Using Papyrus neon and Acceleo 3.7 for SysML 1.4 diagram, the getAppliedStereotype()returns null.
The modules are
[module generate('http://www.eclipse.org/uml2/5.0.0/UML',
'http://www.eclipse.org/papyrus/sysml/1.4/SysML',
'http://www.eclipse.org/papyrus/sysml/1.4/SysML/Blocks',
'http://www.eclipse.org/papyrus/sysml/1.4/SysML/Activities',
'http://www.eclipse.org/papyrus/sysml/1.4/SysML/Requirements',
'http://www.eclipse.org/papyrus/sysml/1.4/SysML/ModelElements')]
I have added the following code in the generate.java but still cannot work
Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
// UML2 profiles
URI uri = URI.createURI("platform:/plugin/org.eclipse.uml2.uml.resources");
uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri.appendSegment("metamodels").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri.appendSegment("profiles").appendSegment(""));
// SysML profiles
uri = URI.createURI("platform:/plugin/org.eclipse.papyrus.sysml14");
uriMap.put(URI.createURI(SysMLResource.LIBRARIES_PATHMAP), uri.appendSegment("librairies").appendSegment(""));
uriMap.put(URI.createURI("pathmap://SysML14_PROFILES/"), uri.appendSegment("model").appendSegment(""));
The code like c.getAppliedStereotypes() returns null. I want to get the information of a requirement like the following code which returns nothing because of the getAppliedStereotype operation:
[for (re : uml::Class | uml::Class.allInstances()->select(cl : uml::Class | cl.getAppliedStereotype('SysML::Requirements::Requirement') <> null))]
--[re.name/]
Modellpfad : [re.qualifiedName/]
Id : [re.getValue(re.getAppliedStereotype('SysML::Requirements::Requirement'), 'id')/]
Text : [re.getValue(re.getAppliedStereotype('SysML::Requirements::Requirement'), 'text')/]
[/for]
Well, if none of your model elements have an applied stereotype, you will find no classes or objects. Thus, when you try to print the applied stereotype of all elements with an applied stereotype without first ensuring that the list is itself not null, you will fail.
Environment : Rails 3.1.1 and Rspec 2.10.1
I am loading all my application configuration through an external YAML file. My initializer (config/initializers/load_config.rb) looks like this
AppConfig = YAML.load_file("#{RAILS_ROOT}/config/config.yml")[RAILS_ENV]
And my YAML file sits under config/config.yml
development:
client_system: SWN
b2c_agent_number: '10500'
advocacy_agent_number: 16202
motorcycle_agent_number: '10400'
tso_agent_number: '39160'
feesecure_eligible_months_for_monthly_payments: 1..12
test:
client_system: SWN
b2c_agent_number: '10500'
advocacy_agent_number: 16202
motorcycle_agent_number: '10400'
tso_agent_number: '39160'
feesecure_eligible_months_for_monthly_payments: 1..11
And I access these values as, For example AppConfig['feesecure_eligible_months_for_monthly_payments']
In one of my tests I need AppConfig['feesecure_eligible_months_for_monthly_payments'] to return a different value but am not sure how to accomplish this. I tried the following approach with no luck
describe 'monthly_option_available?' do
before :each do
#policy = FeeSecure::Policy.new
#settlement_breakdown = SettlementBreakdown.new
#policy.stub(:settlement_breakdown).and_return(#settlement_breakdown)
#date = Date.today
Date.should_receive(:today).and_return(#date)
#config = mock(AppConfig)
AppConfig.stub(:feesecure_eligible_months_for_monthly_payments).and_return('1..7')
end
.....
end
In my respective class I am doing something like this
class Policy
def eligible_month?
eval(AppConfig['feesecure_eligible_months_for_monthly_payments']).include?(Date.today.month)
end
....
end
Can someone please point me in the right direction!!
The method that is being called when you do AppConfig['foo'] is the [] method, which takes one argument (the key to retrieve)
Therefore what you could do in your test is
AppConfig.stub(:[]).and_return('1..11')
You can use with to setup different expectations based on the value of the argument, ie
AppConfig.stub(:[]).with('foo').and_return('1..11')
AppConfig.stub(:[]).with('bar').and_return(3)
You don't need to setup a mock AppConfig object - you can stick your stub straight on the 'real' one.