Hello,
Noob here with 5.x, I am looking for a vb.net solution to notify me when a test has failed.
I have done some searching on the forum and found this link however it is written in C, and when I tried to convert it I ran into all sorts of problems that my noob-fu is not strong enough to fix.
http://www.ranorex.com/blog/wp-content/ ... ogging.zip
Could someone please post or point me to a working solution written in VB that I could learn from?
Also, I am assuming that some sort of 'event handler' is used so that no matter where a failure occurs the send Mail module would fire. That is to say without having to check in multiple places in the code if any error is raised, call the send mail function.
Thank you
Trying to send email on failure using VB.Net
-
- Posts: 30
- Joined: Thu Feb 13, 2014 10:29 pm
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Trying to send email on failure using VB.Net
Hello fester13579,
Please find attached a VisualBasic “report to mail”- solution . It is pretty comprehensive so I guess all your requirements are met within this solution.
Regards,
Robert
Please find attached a VisualBasic “report to mail”- solution . It is pretty comprehensive so I guess all your requirements are met within this solution.
Regards,
Robert
You do not have the required permissions to view the files attached to this post.
Re: Trying to send email on failure using VB.Net
I would recommend using a continuous integration solution like Jenkins (free) or Bamboo ($$) to do this.
I use Jenkins and have it set to send emails on build failures (there are plugins for this as well as some of the other things I do with it). Basically, Ranorex will throw an exit code of 1 if there was a failure in the test, and Jenkins will pick up any exit code that is NOT 0 as a failure of the build, so it will mark the build failed and send an email to the selected recipients.
There are other valuable things you get with Jenkins as well, such as scheduling, environment control (I use virtual machines and Jenkins will make sure they are setup correctly for the tests), etc.
I have several different test regression suites that each have their own job that I then bundle (plugin) in a REGRESSION job. The REGRESSION job will run each test job in succession until they are all done. It will also re-run the whole thing if any of the jobs fail (another plugin). I have the REGRESSION job set to run at 8pm local time every night.
Bamboo does most of these things out of the box, so you don't need the plugins, but it does cost money for each worker (so for my tests, I would have to pay over $8000 for the whole thing because I have a lot of workers) so it can be expensive.
I use Jenkins and have it set to send emails on build failures (there are plugins for this as well as some of the other things I do with it). Basically, Ranorex will throw an exit code of 1 if there was a failure in the test, and Jenkins will pick up any exit code that is NOT 0 as a failure of the build, so it will mark the build failed and send an email to the selected recipients.
There are other valuable things you get with Jenkins as well, such as scheduling, environment control (I use virtual machines and Jenkins will make sure they are setup correctly for the tests), etc.
I have several different test regression suites that each have their own job that I then bundle (plugin) in a REGRESSION job. The REGRESSION job will run each test job in succession until they are all done. It will also re-run the whole thing if any of the jobs fail (another plugin). I have the REGRESSION job set to run at 8pm local time every night.
Bamboo does most of these things out of the box, so you don't need the plugins, but it does cost money for each worker (so for my tests, I would have to pay over $8000 for the whole thing because I have a lot of workers) so it can be expensive.
Shortcuts usually aren't...
-
- Posts: 30
- Joined: Thu Feb 13, 2014 10:29 pm
Re: Trying to send email on failure using VB.Net
Thank you for the replies,
This pre-converted C to VB file SendReportAndStatusPerMail.zip has some issues for me that do not work as expected.
I can get it to mail me the result but every time it sends the email all I get is PASSED regardless of the actual status and no details in the body of the email other than the header:
To use this test I disabled all the steps in recording1 other than step6 (close calc) and then kicked off the test with calc not running to simulate a failure.
It seems that the value of 'success' never gets changed which I think is part of the problem but im not sure what to do to fix it. Checksuccess() never gets called, nor do a lot of the other subs/functions but that may be ok.
Also, This project makes references to older versions of ranorex (2.x & 3.x) , could it be that this code does not work with 5.x or something is lost in the C to VB conversion?
Thanks.
This pre-converted C to VB file SendReportAndStatusPerMail.zip has some issues for me that do not work as expected.
I can get it to mail me the result but every time it sends the email all I get is PASSED regardless of the actual status and no details in the body of the email other than the header:
Ranorex Test Report
Summary: PASSED
Time Level Category Message
To use this test I disabled all the steps in recording1 other than step6 (close calc) and then kicked off the test with calc not running to simulate a failure.
It seems that the value of 'success' never gets changed which I think is part of the problem but im not sure what to do to fix it. Checksuccess() never gets called, nor do a lot of the other subs/functions but that may be ok.
Also, This project makes references to older versions of ranorex (2.x & 3.x) , could it be that this code does not work with 5.x or something is lost in the C to VB conversion?
Thanks.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Trying to send email on failure using VB.Net
Hi fester,
The visual basic project was tested using Ranorex 5 so there shouldn’t be any issues related to the transformation. Did you modify following part of the program.vb file?
Robert
The visual basic project was tested using Ranorex 5 so there shouldn’t be any issues related to the transformation. Did you modify following part of the program.vb file?
'select a specific report level for the email body MailLogger.ReportLevelMail = ReportLevel.SuccessRegards,
Robert
-
- Posts: 30
- Joined: Thu Feb 13, 2014 10:29 pm
Re: Trying to send email on failure using VB.Net
I deleted and re-extracted the zip and I am changing only the following 4 lines in the project:
When I do this I still get PASSED as my state in the email even though the test failed.
I have also upgraded to 5.03 with the same result.
If I force success=False right before this line in Maillogger.vb:
then everything seems to work correctly and i get FAILED.
Thanks
Code: Select all
Program.vb
MailLogger.Host = "smtp.myhost.com"
mailLogger__1 = New MailLogger("[email protected]", "[email protected]", "Message")
MailLogger.ReportLevelMail = ReportLevel[b].failure[/b]
Maillogger.vb:
smtpClient.EnableSsl = false
When I do this I still get PASSED as my state in the email even though the test failed.
Code: Select all
Jump to itemEdit in SpyView Help
Failed to find item 'SendReportAndStatusPerMailRepository.Calculator.Close'.
No element found for path '/form[@title='Calculator']/titlebar/button[@accessiblename='Close']' within 1m. Show/Hide Stacktrace
I have also upgraded to 5.03 with the same result.
Code: Select all
[2014/05/27 11:03:13.670][Debug ][Logger]: Console logger starting.
[2014/05/27 11:03:13.779][Info ][Test]: Test Suite 'SendReportAndStatusPerMail
' started.
[2014/05/27 11:03:13.810][Info ][Test]: Test Case 'TestCase' started.
[2014/05/27 11:03:13.842][Info ][Test]: Test Module 'Recording1' started.
[2014/05/27 11:03:13.888][Info ][Mouse]: Mouse Left Click item 'Calculator.Clo
se' at 20;5.
[2014/05/27 11:04:14.260][Error ][Module]: Failed to find item 'SendReportAndSt
atusPerMailRepository.Calculator.Close'.<br/>No element found for path '/form[@t
itle='Calculator']/titlebar/button[@accessiblename='Close']' within 1m.
[2014/05/27 11:04:14.354][Failure][Test]: Test Module 'Recording1' completed wit
h status 'Failed'.
[2014/05/27 11:04:14.370][Info ][Test]: Test Module 'Recording2' started.
[2014/05/27 11:04:14.401][Info ][User]: The test case failed!
[2014/05/27 11:04:14.494][Info ][Link]: <a href='http://www.ranorex.com/'>Visi
t www.ranorex.com!</a>
[2014/05/27 11:04:14.510][Success][Test]: Test Module 'Recording2' completed wit
h status 'Success'.
[2014/05/27 11:04:14.526][Failure][Test]: Test Case 'TestCase' completed with st
atus 'Failed'.
[2014/05/27 11:04:14.541][Failure][Test]: Test Suite 'SendReportAndStatusPerMail
' completed with status 'Failed'.
If I force success=False right before this line in Maillogger.vb:
Code: Select all
mail.Body = "Summary: " & (If(success, "PASSED", "FAILED")) & vbLf & vbLf & mail.Body
Thanks
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Trying to send email on failure using VB.Net
Hi fester,
Unfortunately we were not able to reproduce the issue. If you change the following line in your program.vb
you should just retrieve notification about failed test actions.
Regards,
Robert
Unfortunately we were not able to reproduce the issue. If you change the following line in your program.vb
you should just retrieve notification about failed test actions.
Code: Select all
MailLogger.ReportLevelMail = ReportLevel.Failure
Robert