How to get the passed and failed test cases count from Extent Report html - extentreports

How to get the passed and failed test cases count from Extent Report html and display the counts in the Console after Selenium test execution

In your TestLister you can set on methods:
onTestFailure
onTestSuccess
the next variables:
int failTC = 0;
int passTC = 0
and then in the methods add +1 and onFinish print the results.

Related

Q# Program does not contain a static 'Main' method suitable for an entry point

I'm creating a program in Q#.
Problem
You are given two qubits in state |00⟩. Your task is to create the following state on them:
1/3–√(|00⟩+|01⟩+|10⟩)
You have to implement an operation which takes an array of 2 qubits as an input and has no output. The "output" of your solution is the state in which it left the input qubits.
Code
namespace Solution {
open Microsoft.Quantum.Primitive;
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Math;
open Microsoft.Quantum.Convert;
operation Solve (qs : Qubit[]) : Unit
{
body
{
Ry(ArcCos(Sqrt(2.0/3.0))*2.0,qs[0]);
(ControlledOnInt(0,H))([qs[0]],qs[1]);
}
}
}
But when I run it show me the following error.
Error
CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point
[C:\Users\Pawar\Desktop\HK\codeforces\Q#\Solution\Solution.csproj]
So I tried to put EntryPoint() before the method declaration . Which shows me different error as
error QS6231: Invalid entry point. Values of type Qubit may not be used as arguments or return values to entry points. [C:\Users\Pawar\Desktop\HK\codeforces\Q#\Solution\Solution.csproj]
Please help me how to run it properly ?
thanks ✌️
In order to run a Q# program as an executable, you need to have an #EntryPoint() operation defined. You can read more in this excellent blog post: https://qsharp.community/blog/qsharp-entrypoint/.
Specifically, in your case, the error message indicates that Qubit[] is not a valid parameter to the main entry point of your program. Which makes sense, because it doesn't make sense to pass an array of qubits when executing a program from the command line. And also, your operation doesn't print anything or return any results, so you won't be able to see what it's doing.
You should probably create an #EntryPoint() wrapper operation that invokes your existing operation with the appropriate parameters, maybe prints some diagnostics, and then returns some result. In your case, you could perhaps do something like this (note the additional namespaces you need to open):
open Microsoft.Quantum.Diagnostics;
open Microsoft.Quantum.Measurement;
#EntryPoint()
operation SolveForTwoQubits() : Result[]
{
using (qubits = Qubit[2])
{
Solve(qubits); // invoke your existing Solve operation
DumpMachine(); // outputs the state of your qubits
let results = MultiM(qubits); // measure the qubits
ResetAll(qubits); // reset the qubits to the initial state
return results; // return the measured results
}
}
This will give some output that looks like:
# wave function for qubits with ids (least to most significant): 0;1
∣0❭: 0.577350 + 0.000000 i == ******* [ 0.333333 ] --- [ 0.00000 rad ]
∣1❭: 0.577350 + 0.000000 i == ******* [ 0.333333 ] --- [ 0.00000 rad ]
∣2❭: 0.577350 + 0.000000 i == ******* [ 0.333333 ] --- [ 0.00000 rad ]
∣3❭: 0.000000 + 0.000000 i == [ 0.000000 ]
[Zero,One]

rkafka.read() doesn't return a message (Returns double quotes only)

Trying to return a message through rkafka library in R.
Followed the same rkafka documentation # https://cran.r-project.org/web/packages/rkafka/vignettes/rkafka.pdf
Output returns "" without the actual message in it. Kafka tool confirms that the message is sent by the producer.
CODE:
prod1=rkafka.createProducer("127.0.0.1:9092")
rkafka.send(prod1,"test","127.0.0.1:9092","Testing once")
rkafka.closeProducer(prod1)
consumer1=rkafka.createConsumer("127.0.0.1:2181","test")
print(rkafka.read(consumer1))
Output:
[1] ""
Desired Output would return "Testing once".
In order to read the messages of a topic that have already been written to the topic (before the consumer has been started) you need to set offset value to the smallest possible (equivalent to --from-beginning). According to rkafka docs autoOffseetReset argument defaults to largest
autoOffsetReset
smallest : automatically reset the offset to the
smallest offset largest : automatically reset the offset to the
largest offset anything else: throw exception to the consumer
Required:Optional Type:String default:largest
In order to be able to consume messages you need to set autoOffsetReset to "smallest".
consumer1=rkafka.createConsumer("127.0.0.1:2181","test", autoOffsetReset="smallest")
Update: This Code Works:
library(rkafka)
prod1=rkafka.createProducer("127.0.0.1:9092")
rkafka.send(prod1,"test","127.0.0.1:9092","Testing once")
rkafka.send(prod1,"test","127.0.0.1:9092","Testing twice")
rkafka.closeProducer(prod1)
consumer1=rkafka.createConsumer("127.0.0.1:2181","test",groupId = "test-consumer-
group",zookeeperConnectionTimeoutMs = "100000",autoCommitEnable = "NULL",
autoCommitInterval = "NULL",autoOffsetReset = "NULL")
print(rkafka.read(consumer1))
print(rkafka.readPoll(consumer1))
rkafka.closeConsumer(consumer1)
The key is to restart Kafka after deleting the logs it generates.

How to increase search size > 10,000 in elasticsearch in R?

I have been trying to query elasticsearch from R using elastic package.
I was able to query and get data with
`Search(index = "tmp_test_data",
q = "_type: random AND log.type: regular", size = 10000)`
However, when I try to increase the size by adding body
`body1 <- '{"settings" : {"index" : {"max_result_window" : "170000"}}}'`
to the search query
`Search(index = "tmp_test_data",
q = "_type: random AND log.type: regular", body = body1)`
it returns, Error: 400 - Unknown key for a START_OBJECT in [settings].
Edit:
I have tried looping through using the from argument in search function with each search size = 1000 which is returning upto 10,000 records and throws Error: 500 - all shards failed after that.
I have also tried with elastic::scroll, tm_scroll = "5m" in the search function by following some of the examples given in the R documentation/help but it is returning the same error Error: 500 - all shards failed.
What is the appropriate way to increase the size of query in R elasticsearch?
You are trying to update a dynamic index setting. You cannot include it as part of a search.
To update it, you need to update it using the Update Settings API. I'm not sure how to do it with R but here is a http request example.
PUT http://myserver:9200/tmp_test_data/_settings
{
"index" : {
"max_result_window": 170000
}
}

QTP Script to Get Field Values from QC

I want to get the count of status(Pass/Fail) of all testcases present in QC by checking the execution grid.
What is the method to retrieve the status and execution date of a test case ?
Currently I am only able to get the test case name.
Code:
Set treeMgr = gTDConn.TestSetTreeManager
Set tstTree = treeMgr.NodeByPath(TestSetPath)
Set tstFactory = tstTree.testSetFactory
Set tsetList = tstFactory.NewList("")
For Each tset In tsetList
msgbox tset.Name
next

DateTime parsing in PowerShell

I'm trying to write a PowerShell script that will generate a table of information with two columns: a name, and a date (which will be retrieved from a third-party application - in this case svn.exe).
The overall script works well, but I'm struggling to get the date that the server sends back into the DataTable. Here's a simplified version of my script:
# Set up a DataTable and initialise columns
$table = New-Object system.Data.DataTable “Test Table”
$col1 = New-Object system.Data.DataColumn Name,([string])
$col2 = New-Object system.Data.DataColumn DateFromServer,([DateTime])
$table.columns.add($col1)
$table.columns.add($col2)
# Create a new row and add the data
$row = $table.NewRow()
$row.Name = "Test"
$lastCommit = GetDateFromExternalApp
$lastCommit.GetType() # this returns DateTime as I would expect
$row.DateFromServer = $lastCommit # this throws up an error
$table.Rows.Add($row)
# Output the table
$table | Format-Table -AutoSize
# This function simulates what the actual function does
# (the real one goes to SVN and pulls down data, but it
# ends up with the same resulting date)
Function GetDateFromExternalApp
{
$externalAppDate = "2012-09-17T16:33:57.177516Z"
return [DateTime]($externalAppDate)
}
The problem (noted in comments in the script above) is that while the function seems to be happily returning a DateTime instance, when I try to add this into the table row's DateFromServer column it's throwing up an error:
Exception setting "DateFromServer": "Unable to cast object of type 'System.Management.Automation.PSObject' to type 'System.IConvertible'.Couldn't store <18/09/2012 2:33:57 AM> in DateFromServer Column. Expected type is DateTime." At line:13 char:6
+ $row. <<<< DateFromServer = $lastCommit
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
However, the call to $lastCommit.GetType() shows that this is indeed a DateTime - and in fact if I add this line somewhere in the script:
$lastCommit
then I can see a nicely formatted datetime, suggesting that it is indeed parsing it and converting it correctly:
Date : 18/09/2012 12:00:00 AM
Day : 18
DayOfWeek : Tuesday
DayOfYear : 262
Hour : 2
Kind : Local
Millisecond : 177
Minute : 33
Month : 9
Second : 57
Ticks : 634835324371775160
TimeOfDay : 02:33:57.1775160
Year : 2012
DateTime : Tuesday, 18 September 2012 2:33:57 AM
As such I'm quite puzzled as to why I'm getting the exception above. I realise that PowerShell does function return values differently than C#, but it looks to me like the function is returning the right type!
The issue here is due to a bug in PowerShell's type adaptation system (I would recommend reporting this to Microsoft if you have not already done so).
When you work with objects in PowerShell, you are actually working with a PSObject wrapper. Most calls (like GetType) are forwarded to the underlying object, though you can add additional members that do not interact with the object itself:
PS> Get-Date | Add-Member NoteProperty Yowza 'for example' -PassThru | Format-List y*
Yowza : for example
Year : 2012
Normally this is not an issue, as PowerShell has extensive type coercion capabilities. In the case of DataRow however, there appears to be a bug with the DataRowAdapter type used to support the property access syntax. If you use the indexer directly, $row['DateFromServer'] = $lastCommit instead of $row.DateFromServer, the value is correctly unwrapped before it is sent to the .NET type.
You can also get around this by unwrapping the value yourself, either using a cast (as vonPryz already showed: [DateTime]$lastCommit), or by retrieving the BaseObject ($lastCommit.PSObject.BaseObject).
I'd like to know the reason for this behaviour too.
Anyway, you can work around the problem by casting the date variable as DateTime or by explicitly declaring it to be one. Like so,
...
$row.DateFromServer = [DateTime]$lastCommit # Doesn't throw exception
...
Or
...
[DateTime]$lastCommit = GetDateFromExternalApp
$row.DateFromServer = $lastCommit # Doesn't throw exception
...
I suspect the reason is as stated in the error message:
"Unable to cast object of type 'System.Management.Automation.PSObject' to type 'System.IConvertible'...Expected type is DateTime." At line:13 char:6
What that is saying is that PowerShell tried to convert $lastCommit into a date and time but failed. The best way is, as vonPryz suggests - cast it to [datetime]
To see the issue more clearly, try looking at the both:
$lastcommit.gettype() and
$row.DateFromServer.gettype()
I don't have the GetDateFromExternalApp to check

Resources