Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8798209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:01:51+00:00 2026-06-14T00:01:51+00:00

I have the following pseudo code public function testSomething() { // assert something //

  • 0

I have the following pseudo code

public function testSomething() {
    // assert something
    // assert something else

    $this->setExpectedException(...);
    // trigger my exception here

    // do one last thing
}

The issue I see, code after the exception being triggered is never made. Is this correct?

This is just a general wondering here – if this is normal I will refactor my test to perform the try/catch directly and fail() the test if nothing is caught.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T00:01:57+00:00Added an answer on June 14, 2026 at 12:01 am

    The code after the exception should not be made. Think of the setExpectedException as making the test into a try -- catch So the code after the exception is thrown will not be executed.

    If you need to do/check things after the exception, you should catch it. Though one warning with your catch, be specific about what exception is being thrown. PHPUnit throws exceptions for failed tests and you could accidentally catch this exception which may result in your test falsely passing.

    Update:
    If the code that you are executing is cleaning up, consider also moving it into the tearDown method of the test.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a test database design like this: The following is the pseudo-code: //BhillHeader
I have a following pseudo-code. public boolean onContextItemSelected(MenuItem aItem) { switch(aItem.getItemId()) { case A:
I have the following spring pseudo-code wired scala class. @Service class Something { @Value(${some.property})
The following (pseudo-) code induces some behaviour which I dont understand. I have 2
I have the following piece of pseudo-C/Java/C# code: int a[]= { 30, 20 };
following piece of code: class a{ public function __get($key) { if($key == 'obj') {
i have following pseudo code : void siftup(int n) pre condition n>0 && heap(1,n-1)
I have the following (pseudo) code root = _iface.createRoot(...) Label l = new Label(hello
I have the following code C++ pseudo code class A { private: B s_staticvar;
I have the following problem illustrated by the pseudo code below (might not make

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.