How to get mail when a program test is failed in Coded UI test with Microsof Visual Studio? - email

I've created many test cases. I want to be emailed by MSV when coded ui test failed. I tried SMPT format but I dont know how to write true code for it. I mean I can send an e mail myself but it doesnt depend on whether test is fail or not. How can I?
Thanks yo!

Since you have so many test cases, are you expecting mail for each and every failed scenario individually or all failed scenarios as a whole (one time email) at the end of the test run?
If you want to send mail for all failed scenarios individually then follow below steps.
Under TestCleanup check the UnitTestOutcome.Failed is true or not.
If it is true it means that a particular test method failed.
Based on this under this condition you can send a mail from here.
If you need a single mail then store all failed information in any format you want and in AssemblyCleanup you can keep the mail code so that it executes at the end of all the test.
Note having screenshots and Exception inside the mail is related to how you are handling reports in your projects. This is just an idea for you questions.

Related

How to write Integration test: Forced logout by logging in from another terminal? #Flutter

I am using webview for logging in my application. If i log in that account on device A, device B automatically logs out. Thanks for the help
There are a couple different paths you could take on this one:
1. Fake the check if another device logs out.
For this one, whatever call you make to see if the user should automatically log out, inject a mock or a fake to force it to say "yes, log out".
I'd suggest combining this with a separate test on the backend that ensures that when someone logs in, the old credentials are flagged as expired as well. Between the two, you have good coverage that the system as a whole works.
2. Manually test this functionality with two devices.
This is pretty self explanatory, but trying to get two separate automated tests to run in the proper order on two different devices consistently is probably not worth the effort. Especially when a quick manual test can verify this functionality when a full end to end validation is required.
It wouldn't be a bad idea to do both options above. #1 for quick validations during development, then do #2 as part of your major release process.

Automated email cakephp 3.x

I am trying to develop a system which allows the user to enter a date and time. Then at entered time the system send an email to the user. I already have the system. All I am looking for is a way to send emails at a given time. I can send emails but cannot programme them to be sent on a precise date and time. Can you help me please? Thanks in advance.
This problem could be solves by using a "cron job" that checks at some interval whether there's any emails to be send now.
You could simply make a single Cake Shell (http://book.cakephp.org/3.0/en/console-and-shells.html) and use some built-in task runner (eg. cron on linux) - but you could also use a plugin for this principle and have that part set up for you.
For a quick'n'easy plugin that works for lots of sites: https://github.com/dereuromark/cakephp-queue.
The functionality you're asking is even built into this plugin already! :)
You'll have got create a class like this: https://github.com/dereuromark/cakephp-queue/blob/master/src/Shell/Task/QueueExampleTask.php#L74 and then just create a new job of this task and set the notbefore parameter to the time you want this email to be sent.
Check the readme here: https://github.com/dereuromark/cakephp-queue/tree/master/docs.
Remark: The email will be sent when the worker executes the given task, so it will be x time after the notbefore property, depending on your amount of workers and jobs - and how long time they'll take to execute.

Azure WebJob Logging/Emailing

I've converted a console app into a scheduled WebJob. All is working well, but I'm having a little trouble figuring out how to accomplish the error logging/emailing I'd like to have.
1.) I am using Console.WriteLine and Console.Error.WriteLine to create log messages. I see these displayed in the portal when I go to WebJob Run Details. Is there any way to have these logs saved to files somewhere? I added my storage account connection string as AzureWebJobsDashboard and AzureWebJobsStorage. But this appears to have just created an "azure-webjobs-dashboard" blob container that only has a "version" file in it.
2.) Is there a way to get line numbers to show up for exceptions in the WebJob log?
3.) What is the best way to send emails from within the WebJob console app? For example, if a certain condition occurs, I may want to have it send me and/or someone else (depending on what the condition is) an email along with logging the condition using Console.WriteLine or Console.Error.WriteLine. I've seen info on triggering emails via a queue or triggering emails on job failure, but what is the best way to just send an email directly in your console app code when it's running as a WebJob?
How is your job being scheduled? It sounds like you're using the WebJobs SDK - are you using the TimerTrigger for scheduling (from the Extensions library)? That extensions library also contains a new SendGrid binding that you can use to send emails from your job functions. We plan on expanding on that to also facilitate failure notifications like you describe, but it's not there yet. Nothing stops you from building something yourself however, using the new JobHostConfiguration.Tracing.Trace to plug in your own TraceWriter that you can use to catch errors/warnings and act as you see fit. All of this is in the beta1 pre-release.
Using that approach of plugging in a custom TraceWriter, I've been thinking of writing one that allows you to specify an error threshold/sliding window, and if the error rate exceeds, an email or other notification will be sent. All the pieces are there for this, just haven't done it yet :)
Regarding logging, the job logs (including your Console.WriteLines) are actually written to disk in your Web App (details here). You should be able to see them if you browse your site log directory. However, if you're using the SDK and Dashboard, you can also use the TextWriter/TraceWriter bindings for logging. These logs will be written to your storage account and will show up in the Dashboard Functions page per invocation. Here's an example.
Logs to files: You can use a custom TraceWriter https://gist.github.com/aaronhoffman/3e319cf519eb8bf76c8f3e4fa6f1b4ae
Exception Stack Trace Line Numbers: You will need to make sure your project is built with debug info set to "full" (more info http://aaron-hoffman.blogspot.com/2016/07/get-line-numbers-in-exception-stack.html)
SendGrid, Amazon Simple Email Service (SES), etc.

Process mail bursts one at a time

we receive bursts of mails from our IDS that we are postprocessing to create incident reports, forward them to request tracker, etc. Right now, we have one script that does all the postprocessing that is called by procmail according to rules in /etc/aliases. Something like:
ids-report: "|/opt/ids/process.pl"
Now, the problem is that running many instances of this script because of mail bursts can lead to memory depletion and some synchronization nastyness.
In my script, I tried using Sys::RunAlone, but found it suboptimal.
I would like procmail to feed my script one mail from queue at a time, but I have not found a way to do it.
Do you guys have any idea, what could I do? Out-of-the-box solutions are welcomed too...
Thanks.
Why not save every mail to a file or database as soon as you receive them and process the saved records one at a time from another script ?
If you post some code you may receive more (and possibly better) answers :)
I second Georgi Rangelov's answer but if you are seriously asking how to run only one message at a time in Procmail, the answer is to use a lock file.
:0:only1.lock
| /opt/ids/process.pl
This means, if the file only1.lock exists, wait. Once it's gone, create it, run the pipe, and then remove the lock file when done.
See also http://porkmail.org/era/procmail/mini-faq.html#locking
"IMAP with idle" mailbox as buffer/pipeline of email messages
You may deliver messages to IMAP mailbox. You can use fetchmail with --idle (to get real time processing) and --mda (to execute your script).
You can make procmail deliver messages to maildir as use dovecot even without daemon running to allow fetchmail access maildir using IMAP protocol.
P.S. I may provide a few more details if you are interested. AFAIR I had used it to handle spams catched by my spamtrap server.

RPC not working on addclose handler

I'm facing a weird problem in GWT. I generate an excel file on server side for users to download. But after the download the file should get deleted.
I have put logic to delete it on server-Side on 2 occasions. One when user logs out and another when browser is closed.
When the user logs out, it works perfectly as it has enough time to make a call to the server whereas in case of addclosehandler, it loses connection and file remains as it is.
i.e. the method on server side does not get executed.
I tried to find another way to call the method directly by importing the package and inheriting in gwt.xml. But an error was thrown at the compile time and rightly so that server side cant be inherited.
Please get me out of this.
Thanks in advance.
But after the download the file should get deleted. I have put logic
to delete it on server-Side on 2 occasions.
This does not have to do anything with the client. I don't know excactly how your progam works but generally it should work like this:
Client makes a request
Servlet generates the bytes (Is there really a need to store the bytes in a file?)
sends them to client
And that's it.