Skip to main content

Basic Web Performance Testing With JMeter and Gatling

Introduction

In this post I'll give a quick way to get some basic web performance metrics using both JMeter and Gatling.

JMeter is a well known, open source, Java based tool for performance testing. It has a lot of features, and can be a little confusing at first. Scripts (aka Test Plans), are XML documents, edited using the JMeter GUI.  There are lots of options, supports a wide variety of protocols, and produces some OK looking graphs and reports.

Gatling is a lesser known tool, but I really like it. It's a Scala based tool, with scripts written in a nice DSL. While the scripts require some basic Scala, they are fairly easy to understand and modify. The output is a nice looking, interactive, HTML page.

Metrics 

Below are the basic metrics gathered by both JMeter and Gatling. If you are just starting performance testing, these might be a good starting point.

Response Time – Difference between time when request was sent and time when response has been fully received

Latency – JMeter and Gatling define latency as the difference between time when request was sent and when response has started to be received, which includes the time the server spends processing the request.

Throughput – JMeter and Gatling define throughput as the number of requests per second. It is a measure of the load placed on the server during the test.

Installation

Setting up both JMeter and Gatling  is simply a matter of installing Java, and downloading the JMeter and Gatling binaries to your machine.

JMeter 2.11 can be downloaded here. Gatling 1.5.5 binaries can be downloaded here.

I've used the Oracle JDK 7 to run both JMeter and Gatling. The JDK can be downloaded here.

JMeter


Setting up a simple test plan in JMeter is pretty straightforward.

  1. Add Thread Group. Right Click 'Test Plan', Add 'Threads (Users)'->'Thread Group'. 
  2. Configure number of threads (users) on the Thread Group. (e.g. set to 10 to simulate 10 users)
  3. Configure the ramp up period of the users on the Thread Group (e.g. set to 5 to ramp up the given number of users over a 5 minute period)
  4. Configure the loop count on the Thread Group (e.g. set to 10 for each user to repeat the action 10 times). Check 'Forever' if you want each user to constantly repeat the action indefinitely (simulating the user constantly clicking the refresh button).
  5. Add HTTP Request Sampler. Right Click the new Thread Group, then click Add->Sampler->HTTP Request.
  6. Configure HTTP Request Server or IP. Leave out protocol, and point at the root. (e.g.blog.jerometerry.com)
  7. Configure HTTP Request Path. Set to '/' the HTTP Request Server or IP is the full URL you want to hit. Otherwise, append the relative path of the URL you want to hit (relative to the server)
  8. Add listeners to the Thread Group. For example, you might want tabular results, graph results, response time graph, or summary report. I'd recommend at least 'View Results in Table', along with 'Graph Results'. All listeners are added the same way. Right click the Thread Group, click Add->Listener then pick the listener you want to add.
  9. Save the test plan (from the File Menu).



When the test plan is complete, run it by pressing the green run button in the toolbar.

View Results in Table

Graph Results


Gatling


There is no GUI for editing Gatling scripts, other than a plain old text editor or your IDE of choice.

The first time using Gatling, you might want to use the Gatling Recorder.

Gatling Recorder


  1. Fire up the recorder from the Gatling\bin folder
  2. Configure the proxy server ports (defaults are HTTP 8000, HTTPS 8001)
  3. Configure the Java package that will contain the output Java Class containing the Gatling script (or leave blank for no package)
  4. Configure the class name, to give a descriptive name for the Gatling Simulation, or leave it as the default
  5. Click Start
  6. Configure your browser to use the Gatling proxy server
  7. Load up the page you want to record in your browser
  8. Once your done performing the actions you want the script to take, click the Stop and Save button on the recorder. 
  9. A new Gatling script will be created in the Gatling\user-files\simulations\ folder.

Sample Script

Here's a simple example of a Gatling script.It ramps up 10 users over 5 seconds, where each user loads http://blog.jerometerry.com 10 times each, for total of 100 page requests.

package jterry
import com.excilys.ebi.gatling.core.Predef._
import com.excilys.ebi.gatling.http.Predef._
import com.excilys.ebi.gatling.jdbc.Predef._
import com.excilys.ebi.gatling.http.Headers.Names._
import akka.util.duration._
import bootstrap._
import assertions._

class Blog extends Simulation {

 val httpConf = httpConfig
   .baseURL("http://blog.jerometerry.com")
   .userAgentHeader("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0")

 val scn = scenario("Jerome's Blog")
  .repeat(10) {
            exec(http("blog")
     .get("/")
   )
        }

 setUp(scn.users(10).ramp(5 seconds).protocolConfig(httpConf))
}


 Running Gatling Scripts


To run a Gatling script, you use the Gatling command in the Gatling\bin folder.  If you run Gatling without any options, it will prompt you to select the Simulation you want to run. However, if you know the package and class name, you can use the command "Gatling -s [package].[Class]".



After running a simulation, the HTML results are saved to Gatling\results\



Summary


This was a very basic guide to setting up and running JMeter and Gatling for the first time, assuming little or no previous experience with performance testing or these tools.

With a little bit of effort, it's not too much trouble to get some basic performance metrics on a single web page, including response time, latency and throughput.


Comments

  1. The blog gave me idea about the web performance testing my sincere thanks for sharing this post and please continue to share this kind of post
    Software Testing Training in Chennai

    ReplyDelete
  2. Nice and Valuable information you explained in this article I loved it more, It useful for me a lot. Bookmarked your site.
    Regards,
    Java Online Training

    ReplyDelete
  3. Interesting and informative article.. very useful to me.. thanks for sharing your wonderful ideas.. please keep on updating..


    Software Testing Training in chennai

    ReplyDelete
    Replies
    1. It is very important that you do everything to keep your body in shape if you want to be a football player. The UFA Web game requires a lot of physical exertion, so being out of shape will only make you more susceptible to injury. Dieting and exercising will help you get into good shape.

      Delete
  4. Interesting blog post.This blog shows that you have a great future as a content writer.waiting for more updates...
    Digital Marketing Company in India

    ReplyDelete
  5. Nice blog !!! I agree with your points, Big Data Hadoop technology is ruling the whole organization to handle data in efficient manner. HDFS and Map reduce helps the developer in different ways to manage data.

    Regards:

    Hadoop Training in Chennai |
    Big Data Training in Chennai

    ReplyDelete

  6. Testing an application is become essential for any product to get an effective result. Your post help you to gain more info on Selenium Testing

    Selenium Training in chennai |
    Selenium Training

    ReplyDelete
  7. Thanks for sharing this useful info with us, this post will be useful for beginners those who wish to learn Jmeter. keep on sharing.Jmeter Training Course |
    Jmeter Training Institute in Chennai |
    Jmeter Training |
    Best Jmeter Training Institute in chennai

    ReplyDelete
  8. Thanks for sharing this useful info with us...

    software testing course online

    ReplyDelete
  9. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.


    Best Java Training Institute Chennai

    Java Training Institute Bangalore

    ReplyDelete
  10. Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition.
    big-data-hadoop-training-institute-in-bangalore

    ReplyDelete
  11. Ciitnoida provides Core and java training institute in

    noida
    . We have a team of experienced Java professionals who help our students learn Java with the help of Live Base Projects. The object-

    oriented, java training in noida , class-based build

    of Java has made it one of most popular programming languages and the demand of professionals with certification in Advance Java training is at an

    all-time high not just in India but foreign countries too.

    By helping our students understand the fundamentals and Advance concepts of Java, we prepare them for a successful programming career. With over 13

    years of sound experience, we have successfully trained hundreds of students in Noida and have been able to turn ourselves into an institute for best

    Java training in Noida.

    java training institute in noida
    java training in noida

    ReplyDelete
  12. The blog gave me thought regarding the web execution testing my genuine a debt of gratitude is in order for sharing this post and please keep on sharing this sort of post
    planet-php

    ReplyDelete
  13. Intriguing and educational article.exceptionally helpful to me..a debt of gratitude is in order for sharing your great thoughts.. kindly continue refreshing.

    Article Submission sites| Latest Updates| Technology

    ReplyDelete
  14. This comment has been removed by the author.

    ReplyDelete
  15. Very interesting content which helps me to get the in depth knowledge about the technology. keep sharing... Thanks you
    guest posting sites
    technical updates

    ReplyDelete
  16. This was an nice and amazing and the given contents were very useful and the precision has given here is good.


    Bigdata AnalyticsTraining in Bangalore

    ReplyDelete
  17. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.

    RPA Training in Chennai | Blue Prism Training in Chennai

    ReplyDelete
  18. Thanks you so much for your tips and content, This is great one article,likely its very useful to me. Once again say thanks.

    Selenium Training in Chennai | Selenium Course in Chennai

    ReplyDelete
  19. This comment has been removed by the author.

    ReplyDelete
  20. Thanks for your informative article, Your post helped me to understand the future and career prospects & Keep on updating your blog with such awesome article.
    python training in tambaram | python training in annanagar | python training in jayanagar

    ReplyDelete
  21. I have read a few of the articles on your website now, and I really like your style of blogging. I added it to my favourites blog site list and will be checking back soon.
    advanced excel training in bangalore

    ReplyDelete
  22. I read this post two times, I like it so much, please try to keep posting & Let me introduce other material that may be good for our community.
    Java training in Chennai | Java training in Bangalore

    Java interview questions and answers | Core Java interview questions and answers

    ReplyDelete
  23. This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me
    best rpa training in chennai
    rpa training in chennai |
    rpa online training
    rpa course in bangalore
    rpa training in pune
    rpa training in marathahalli
    rpa training in btm

    ReplyDelete
  24. Inspiring writings and I greatly admired what you have to say , I hope you continue to provide new ideas for us all and greetings success always for you..Keep update more information.


    rpa training in chennai |
    best rpa training in chennai
    rpa online training
    rpa course in bangalore
    rpa training in pune
    rpa training in marathahalli
    rpa training in btm

    ReplyDelete
  25. Nice tutorial. Thanks for sharing the valuable information. it’s really helpful. Who want to learn this blog most helpful. Keep sharing on updated tutorials…
    python course in pune | python course in chennai | python course in Bangalore

    ReplyDelete

  26. This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.

    best rpa training in chennai
    rpa training in chennai |
    rpa online training
    rpa course in bangalore
    rpa training in pune
    rpa training in marathahalli
    rpa training in btm

    ReplyDelete
  27. Excellant post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.

    Java training in Chennai | Java training in Bangalore

    Java interview questions and answers | Core Java interview questions and answers

    ReplyDelete
  28. emails with the same comment. Is there any way you can remove people from that service? Thanks.
    fire and safety course in chennai

    ReplyDelete
  29. I am really enjoying reading your well-written articles. It looks like you spend a lot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work.
    Selenium Training in Chennai
    Selenium Training
    iOS Training in Chennai
    Digital Marketing Training in Chennai
    core java training in chennai
    Selenium Interview Questions and Answers
    PHP Training in Chennai
    PHP Course in Chennai

    ReplyDelete
  30. Nice Article,Great experience for me by reading this info.
    thanks for sharing the information with us.keep updating your ideas.
    Selenium Certification Training in T nagar
    Selenium Courses in T nagar
    Selenium Training Institutes in OMR
    Selenium Courses in OMR

    ReplyDelete
  31. Hello! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done an outstanding job.

    Best AWS Training in Chennai | Amazon Web Services Training in Chennai
    AWS Training in Bangalore | Amazon Web Services Training in Bangalore
    Amazon Web Services Training in OMR , Chennai | Best AWS Training in OMR,Chennai

    ReplyDelete
  32. A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article.
    iosh course in chennai

    ReplyDelete
  33. Sap fico training institute in Noida

    Sap fico training institute in Noida - Webtrackker Technology is IT Company which is providing the web designing, development, mobile application, and sap installation, digital marketing service in Noida, India and out of India. Webtrackker is also providing the sap fico training in Noida with working trainers.


    WEBTRACKKER TECHNOLOGY (P) LTD.
    C - 67, sector- 63, Noida, India.
    F -1 Sector 3 (Near Sector 16 metro station) Noida, India.

    +91 - 8802820025
    0120-433-0760
    0120-4204716
    EMAIL: info@webtrackker.com
    Website: www.webtrackker.com

    ReplyDelete
  34. And indeed, I’m just always astounded concerning the remarkable things served by you. Some four facts on this page are undeniably the most effective I’ve had.'
    fire and safety course in chennai

    ReplyDelete
  35. Thanks for the informative article. This is one of the best resources I have found in quite some time. Nicely written and great info. I really cannot thank you enough for sharing.
    Devops Training in Chennai | Devops Training Institute in Chennai

    ReplyDelete
  36. Great, this article is quite awesome and I have bookmarked this page for my future reference. Keep blogging like this with the latest info.
    DevOps course in Chennai
    Best DevOps Training in Chennai

    ReplyDelete
  37. This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
    aws online training

    data science with python online training

    data science online training

    rpa online training

    ReplyDelete
  38. Thanks For sharing Your Information The Information shared Is Very Valuable Please Keep Updating Us Python Online Course Hadoop Online Course Data Science Online Course Aws Online Course

    ReplyDelete
  39. I am sure this post has helped me save many hours of browsing other related posts just to find what I was looking for. Many thanks!
    Microsoft Azure online training
    Selenium online training
    Java online training
    Python online training
    uipath online training

    ReplyDelete
  40. Such an informative and helpful, Thank you for sharing this wonderful post.


    Data Science Bangalore

    ReplyDelete
  41. Attend The Python training in bangalore From ExcelR. Practical Python training in bangalore Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Python training in bangalore.
    python training in bangalore

    ReplyDelete

  42. It is perfect time to make some plans for the future and it is time to be happy. I’ve read this post and if I could I desire to suggest you few interesting things or tips. Perhaps you could write next articles referring to this article. I want to read more things about it!





    DATA SCIENCE COURSE MALAYSIA

    ReplyDelete
  43. This is also a very good post which I really enjoyed reading. It is not every day that I have the possibility to see something like this,
    Data science Courses banglore

    ReplyDelete
  44. Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. I wanted to thank you for this websites! Thanks for sharing. Great websites!
    Keyword

    ReplyDelete
  45. I Got Job in my dream company with decent 12 Lacks Per Annum salary, I have learned this world most demanding course out there in the current IT Market from the Hadoop training in btm experts who helped me a lot to achieve my dreams comes true. Really worth trying

    ReplyDelete
  46. This comment has been removed by the author.

    ReplyDelete
  47. For Hadoop Training in Bangalore Visit : Hadoop Training in Bangalore

    ReplyDelete
  48. Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more.
    big data analytics courses

    ReplyDelete
  49. Thanks a lot for giving great kind of information. So useful and practical for me. Excellent blog and very informative, nice work keep updating. If you are looking for any Hadoop admin and hadoop related information, check our hadoop admin training institute in bangalore web page. Thanks a lot.

    ReplyDelete
  50. I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it.

    Data Science Course

    ReplyDelete

  51. I have read your blog it is very helpful for us. I couldn't find any knowledge on this matter prior to. I would like to thanks for sharing this article here.

    IELTS Coaching in chennai

    German Classes in Chennai

    GRE Coaching Classes in Chennai

    TOEFL Coaching in Chennai

    spoken english classes in chennai | Communication training

    ReplyDelete
  52. Very interesting and it caught my attention. Bookmarking your article which will probably be my guide. Thank you very much.
    To study aws course visit cognex .
    Cognex Providing world-class training in AWS Certification.
    Providing the most trustworthy AWS course in Chennai.
    AWS Training in Chennai

    ReplyDelete
  53. Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one. Keep posting. Thanks for sharing.
    artificial intelligence ai and deep learning in guduvanchery

    ReplyDelete
  54. Quite Interesting post!!! Thanks for posting such a useful post. I wish to read your upcoming post to enhance my skill set, keep blogging.I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.
    selenium training in chennai

    selenium training in chennai

    selenium online training in chennai

    software testing training in chennai

    selenium training in bangalore

    selenium training in hyderabad

    selenium training in coimbatore

    selenium online training

    selenium training



    ReplyDelete
  55. Salesforce offers a more comprehensive and user-friendly knowledge base for its users. @Salesforce rates better than SAP for knowledge creation workflows in SelectHub's research & analysis of the two #crm tools
    Salesforce Training in Chennai

    Salesforce Online Training in Chennai

    Salesforce Training in Bangalore

    Salesforce Training in Hyderabad

    Salesforce training in ameerpet

    Salesforce Training in Pune

    Salesforce Online Training

    Salesforce Training

    ReplyDelete
  56. The regular visits listed here are the easiest way to appreciate its energy, which is why I go to the website every day for new and interesting information. Thank you so much!

    Data Analytics Course in Bangalore

    ReplyDelete
  57. I really enjoyed reading this post, big fan. Keep up the good work and let me know when you can post more articles or where I can find out more on the topic. PMP Certification in Hyderabad

    ReplyDelete
  58. It is closely related to data mining and mathematical concepts like probability, so a good base in data mining and mathematics will be helpful during the course of data mining. A good base in python also helps. data science course syllabus

    ReplyDelete
  59. Excellant post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
    DevOps Training in Chennai

    DevOps Course in Chennai

    ReplyDelete
  60. Nice article. I liked very much. All the information given by you are really helpful for my research. keep on posting your views.
    business analytics courses aurangabad

    ReplyDelete
  61. Standard visits recorded here are the simplest strategy to value your vitality, which is the reason why I am heading off to the site regularly, looking for new, fascinating information. Many, bless your heart!
    data science training

    ReplyDelete
  62. Incredibly conventional blog and articles. I am realy very happy to visit your blog. Directly I am found which I truly need. Thankful to you and keeping it together for your new post.
    business analytics courses in aurangabad

    ReplyDelete
  63. Truly incredible blog found to be very impressive due to which the learners who ever go through it will try to explore themselves with the content to develop the skills to an extreme level. Eventually, thanking the blogger to come up with such an phenomenal content. Hope you aarrive with the similar content in future as well.

    Machine Learning Course in Bangalore

    ReplyDelete
  64. Title:
    Best Oracle Training in Chennai | Infycle Technologies

    Description:
    Ge set your career towards Oracle with the best Oracle training in Chennai with Infycle Technologies. Infycle offers the best software courses such as Big Data, Java, Python, Hadoop, etc in a complete hands-on training tutored by professionals in the field. Apart from the training, the mock interviews for the placement will be given, so that, they can face the interviews with full confidence. While completing the mock interview, the candidates will be placed in the top MNC's with a great salary package. For all this, call 7502633633 and make this happen for your happy life.
    Best trainingin Chennai

    ReplyDelete
  65. Title:
    Best Oracle PLSQL Training in Chennai | Infycle Technologies

    Description:
    If Server Administrator is a job that you're dreaming of, then we, Infycle are with you to make your dream into reality. Infycle Technologies offers the best Oracle PLSQL Training in Chennai, with various levels of highly demanded software courses such as Oracle DBA, Java, Python, Big Data, etc., in 200% practical hands-on training with experienced tutors in the field. Along with that, the pre-mock interviews will be given for the candidates, so that, they can meet the interviews with complete knowledge. Dial 7502633633 for more.
    Best training in Chenni

    ReplyDelete
  66. Happy to chat on your blog, I feel like I can't wait to read more reliable posts and think we all want to thank many blog posts to share with us.

    Machine Learning Course in Bangalore

    ReplyDelete
  67. Title:
    Grab Data Science Course in Chennai | Infycle Technologies

    Description:
    Data science can be defined as a blend of Mathematics. The entire Data Life Cycle is covered in our Data Science course in Chennai, which includes Data Architecture, Statistics, Advanced Data Analytics, and Machine Learning. To enrol in this course, you must have a basic understanding of statistics and mathematics. We Infycle offer the best Data Science course in Chennai with 200% practical classes, pre-mock interview sessions, and more career counseling classes. For a free demo session, call us at 7502633633.
    best training institute in chennai

    ReplyDelete
  68. Title:
    Best Data Science training in Chennai | Infycle Technologies

    Description:
    Infycle Technologies is the best software training center in Chennai, providing amazing Data Science training in Chennai which will be realistic and taught by industry experts. Aside from practical training preparation, mock interviews will be arranged for students so that they can confidently face the interviews. All of this will be packed up by full placement assurance with the best salary package from top companies. For having a free demo session, call 7502633633.

    best training institute in chennai

    ReplyDelete
  69. Really an awesome blog and very useful information for many people. Keep sharing more blogs again soon. Thank you.
    Data Science Course Institute in Hyderabad

    ReplyDelete
  70. If your car uses more warm-up time, your engine is failing, and that marks the time to order your infallible Suzuki Engine Parts from BP Auto Spares India.

    Suzuki Electrical Parts: Your Suzuki car’s electrical system comprises of the alternator, battery, and the starter. Before you go on long-distance trips, check their health and get the right replacements.

    If your Suzuki car isn’t performing great as in its initial stages, attend to it immediately. Get replacement Suzuki Brake Parts for all your Suzuki brands and drive safely.

    Rejuvenate the look and feel of your Suzuki car with top-notch Suzuki Body Parts. Get custom parts to suit the requirements of individual Suzuki brands.

    If you are unable to halt your car without killing the engine, your Suzuki Clutch Parts have become damaged. Order your replacements now and save your Suzuki car.

    ReplyDelete
  71. This post is so useful and informative. Keep updating with more information.....
    Simple Hacking
    How To Be An Ethical Hacker

    ReplyDelete
  72. Much obliged as a results a reasonable setup as you have been endorsed to share direction thinking us. we can totally praise through and through you have completed here because of the reality you have made my comport your self as pleasantly ventilated as ABC. Crack Hotspot Shield

    ReplyDelete
  73. You understand your tasks stand apart of the group. there might be something exceptional nearly them. It appears to me every one of them are in truth remarkable! FileviewPro Key

    ReplyDelete

  74. At the end of the day, whether or not those people are comfortable with how you're living your life doesn't matter. What matters is whether you're comfortable with it. Quotes For Life

    ReplyDelete
  75. Great job as always! Your posts are consistently insightful and enjoyable, https://www.twohillsseptic.ca/

    ReplyDelete
  76. Looking for a top-rated Ecommerce Website Development Company? Look no further! Our expert team specializes in creating custom ecommerce solutions to drive your online business growth. Contact us today for a consultation.

    ReplyDelete
  77. Great job as always! Your posts are consistently insightful enjoyed a lot. Digital Marketing Courses in Koramangala

    ReplyDelete

Post a Comment

Popular posts from this blog

Generating Java Mixed Mode Flame Graphs

Overview I've seen Brendan Gregg's talk on generating mixed-mode flame graphs  and I wanted to reproduce those flamegraphs for myself. Setting up the tools is a little bit of work, so I wanted to capture those steps. Check out the Java in Flames post on the Netflix blog for more information. I've created github repo ( github.com/jerometerry/perf )  that contains the scripts used to get this going, including a Vagrantfile, and JMeter Test Plan. Here's a flame graph I generated while applying load (via JMeter) to the basic arithmetic Tomcat sample application. All the green stacks are Java code, red stacks are kernel code, and yellow stacks are C++ code. The big green pile on the right is all the Tomcat Java code that's being run. Tools Here's the technologies I used (I'm writing this on a Mac). VirtualBox 5.1.12 Vagrant 1.9.1 bento/ubuntu-16.04 (kernel 4.4.0-38) Tomcat 7.0.68 JMeter 3.1 OpenJDK 8 1.8.111 linux-tools-4.4.0-38 linux-to...

Multi Threaded NUnit Tests

Recently I needed to reproduce an Entity Framework deadlock issue. The test needed to run in NUnit, and involved firing off two separate threads. The trouble is that in NUnit, exceptions in threads terminate the parent thread without failing the test. For example, here's a test that starts two threads: the first thread simply logs to the console, while the other thread turfs an exception. What I expected was that this test should fail. However, the test actually passes. readonly ThreadStart[] delegates = { () => { Console.WriteLine("Nothing to see here"); }, () => { throw new InvalidOperationException("Blow up"); } }; [Test] public void SimpleMultiThreading() { var threads = delegates.Select(d => new Thread(d)).ToList(); foreach (var t in threads) { t.Start(); } foreach (var t in threads) { t.Join(); } } Peter Provost posted an article that describes how to make this test fail. It...