I have some single watir.rb scripts that use IE and are written in a standard watir way.
How do I create a test group that combines them? I want all of them be executed by executing the main script.
Is it possible to auto include single test files into a test group by subidr?
Is it possible to enumerate the files that should be included in the test group?
Can I cascade (include other watir test groups in a watir test group)?
Edit: After much searching and googling I could not find anything.
I will use this simple style for now:
passed = 0
failed = 0
result = system("ruby suite_one.rb") #execute the script and wait for it to finish.
if result #Record our results.
passed = passed + 1
else
failed = failed + 1
end
result = system("ruby suite_two.rb") #execute the script and wait for it to finish.
if result #Record our results.
passed = passed + 1
else
failed = failed + 1
end
puts "failed: "
puts failed
puts "passed: "
puts passed
Take a look how Watir unit tests are executed.
Related
I tried to look everywhere, but no luck so far. I have a collection with 6 requests that run automatically, but I need the last request to run only once at the end of the last iteration.
I tried to use this code in Pre-request Script of Request 5
if (pm.info.iteration === 0) {
postman.setNextRequest("Request 6")
} else {
postman.setNextRequest("Request 1")
}
and expected that the Request 6 would run only once after there is no more iteration to run, but I am doing something wrong since it is still not working.
you kind of mixed up pm.info.iterationCount and pm.info.iteration:
pm.info.iteration The value of the current iteration
pm.info.iterationCount The total number of iterations that are scheduled to run
See the documentation: Scripting with request info
You want to execute "Request 6" at the very end, this means, when iteration and iterationCount are equal.
Note that iteration start at 0, so you need to add + 1 when comparing it to iterationCount.
Also, if this condition does not match, you need to set the nextRequest to null.
"Request 1" will be executed automatically by the Collection Runner. If you set the nextRequest to "Request 1", you will end up in an endless loop.
The following will do you what you want, you can put it as pre-request script or test of "Request 5".
if (pm.info.iterationCount == pm.info.iteration + 1) {
postman.setNextRequest("Request 6")
} else {
postman.setNextRequest(null)
}
Update 2
I accepted an answer and asked a different question elsewhere, where I am still trying to get to the bottom of this.
I don't think that one-lining this query is the answer, as I am still not getting the required results (and multi-lining queries is allowed in .mof, as shown in the URLs in comments to the answer ...
Update
I rewrote the query as a one-liner as suggested, but still got the same error! As it was still talking about lines 11-19 I knew there must be another issue. After saving a new file with the change, I reran mofcomp and it appears to have loaded, but the event which I have subscribed to simply does not work.
I really feel that there is not enough documentation on this topic and it is hard to work out how I am meant to debug this - any help on this would be much appreciated, even if this means using a different more appropriate method.
I have the following .mof file, which I would like to use to register an event on my system :
#pragma namespace("\\\\.\\root\\subscription")
instance of __EventFilter as $EventFilter
{
Name = "Event Filter Instance Name";
Query = "Select * from __InstanceCreationEvent within 1 "
"where targetInstance isa \"Cim_DirectoryContainsFile\" "
"and targetInstance.GroupComponent = \"Win32_Directory.Name=\"c:\\\\test\"\"";
QueryLanguage = "WQL";
EventNamespace = "Root\\Cimv2";
};
instance of ActiveScriptEventConsumer as $Consumer
{
Name = "TestConsumer";
ScriptingEngine = "VBScript";
ScriptText =
"Set objFSO = CreateObject(\"Scripting.FileSystemObject\")\n"
"Set objFile = objFSO.OpenTextFile(\"c:\\test\\Log.txt\", 8, True)\n"
"objFile.WriteLine Time & \" \" & \" File Created\"\n"
"objFile.Close\n";
// Specify any other relevant properties.
};
instance of __FilterToConsumerBinding
{
Filter = $EventFilter;
Consumer = $Consumer;
};
But whenever I run the command mfcomp myfile.mof I am getting this error:
Parsing MOF file: myfile.mof
MOF file has been successfully parsed
Storing data in the repository...
An error occurred while processing item 1 defined on lines 11 - 19 in file myfile.mof:
Error Number: 0x80041058, Facility: WMI
Description: Unparsable query.
Compiler returned error 0x80041058
This error appears to be caused by incorrect syntax in the query, but I don't understand where I have gone wrong with this - is anyone able to advise?
There are no string concatenation or line continuation characters being used in building "Query". To keep it simple, you could put the entire query on one line.
I'm making my first steps in the Jenkins workflow (Jenkins ver 1.609.1)
I need to read a file, line by line, and then run regex on each line.
I'm interested in the regex "grouping" type, however "project" and "status" variables (the code below) get null value in Jenkins . Any suggestions what is wrong and how to fix it ?
def line = readFile (file)
def resultList = line.tokenize()
for(item in resultList ){
(item =~ /(\w+)=(\w+)$/).each { whole, project, status ->
println (whole)
println (project)
println (status)
}
}
each with a closure will not work: JENKINS-26481
If something using advanced language features works in standalone Groovy but not in Workflow, try just encapsulating it in a method marked #NonCPS. This will effectively run it as a “native” method. Only do this for code you are sure will run quickly and not block on I/O, since it will not be able to survive a Jenkins restart.
Well,
After checking out some other regex options I came around with the following solution that seems working :
def matcher = item =~ /(?<proj>\w+)=(?<status>\w+)/
if( matcher.matches() ) { etc...}
im trying to setup some unit tests with Elixir but running into this error below. What am I doing wrong?
cannot invoke remote function PropertyManager.Database.get/0 inside match
Here is my code:
property_manager_test.exs
defmodule PropertyManagerTest do
use ExUnit.Case
test "the truth" do
assert 1 + 1 == 2
end
test "get value from db" do
assert PropertyManager.Database.get() = "test this"
end
end
database.ex
defmodule PropertyManager.Database do
def get do
"test this"
end
end
Try with == instead of =
What you're doing in your code is a pattern match, which means it will try to match the right side to the pattern on the left side. A pattern can't contain function calls, which is probably the cause of your error.
I'm using mocha with chai.js for CoffeeScript unit testing. I have a grunt task to compile the coffee files to the test folder and start PhantomJS to run the mocha tests.
Everything works fine however chai.js only indicates what test is failing and what are the expected and actual values, it does not specify what assertion is not passing in a test case. Is there any good way to print the assertion or at least the index of the assertion that is failing? I also turned on chai.Assertion.includeStack however that only shows the line number in the JavaScript file that is not that helpful for the CoffeeScript tests.
FizzBuzzTest.coffee
fizz = new FizzBuzz()
describe "Print numbers from 1 to 100", ->
it "First 10 digits from 1 to 5", ->
result = fizz.do()
arr = result.split(fizz.Delimiter)
expect(arr[0]).to.equal("1")
expect(arr[1]).to.equal("2")
expect(arr[2]).to.equal(fizz.Fizz)
expect(arr[3]).to.equal("3") # this assertion should fail
expect(arr[4]).to.equal(fizz.Buzz)
Executing tests
$ grunt test
Running "mocha:run" (mocha) task
Testing: Content/runner.html
Print numbers from 1 to 100
✓ First 10 digits from 1 to 5
1) Last 10 digits from 95 to 100
✓ Print FizzBuzz instead of number which is divisible by both 3 and 5
✓ Check number
✓ Check Fizz
✓ Check Buzz
✓ Check FizzBuzz
✓ Check if > 100 then null
✓ Check if < 1 then null
8 passing (113ms)
1 failing
1) Print numbers from 1 to 100 Last 10 digits from 95 to 100:
AssertionError: expected true to be false
at file:///Users/milan/Sites/CoffeeTests/Content/js-libs/chai/chai.js:918
at file:///Users/milan/Sites/CoffeeTests/Content/js-libs/chai/chai.js:1159
at file:///Users/milan/Sites/CoffeeTests/Content/js-libs/chai/chai.js:3563
>> 1/9 tests failed (0.11s)
Warning: Task "mocha:run" failed. Use --force to continue.
Aborted due to warnings.
Question:
Is there a good way to set chai.js to be more specific about where the AssertionError happened?
Like: AssertionError: expected true to be false in line expect(arr[3]).to.equal("3")
Thank you.
If no one comes up with a more sophisticated solution to make chai.Assertion.includeStack work nicely with CoffeeScript code, you can always pass messages to some of the functions in the expect interface:
it("bluh", function () {
chai.expect(false).to.be.equal(true, "here");
});
The "here" string is a message that will be output with the error message when the assertion fails. Take a look at the documentation though because not all functions take an optional message. I first wanted to use to.be.true above but the true method does not take an optional message.
The assert interface supports optional messages on more functions than the expect interface does.