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 7515967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:58:54+00:00 2026-05-30T00:58:54+00:00

I want to test a method which doesn’t return anything. The method starts by

  • 0

I want to test a method which doesn’t return anything. The method starts by asserting that a parameter doesn’t contain an illegal value:

- (void) someMethod:(NSString*)param {
    NSParamaterAssert(param != @"0");
    // more code
}

In my testing code I want to make sure that illegal values are caught, but I don’t want the program exiting during testing. In python I can try: except: to catch it. Is there an equivalent in Objective C? Am I using assertions incorrectly here?

  • 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-05-30T00:58:55+00:00Added an answer on May 30, 2026 at 12:58 am

    You are mixing up “Exceptions” and their “Handling” with assertions.
    (Find more information on assertions here, “Exception Handling” is also on wikipedia but unfortunetaly I’m only allowed to post 2 links).

    Assertions are normally not to be used as a way to preserve your method/program from (usually serious) errors (like wrong function behavior in special cases). Assertions are for example used with verification of programs.

    You want to handle exceptions (like wrong parameters in your case).
    A good starting point for doing so is here (ObjC only).

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

Sidebar

Related Questions

I have a method in a service which I want to test. That method
I'm new to TDD and xUnit so I want to test my method that
I am using NUnit 2.5, and I want to test a method that recieves
I have a method CreateAccount(...) that I want to unit test. Basically it creates
Give a base class Base , I want to write a method Test, like
I want to stress test a web service method by calling it several thousand
I want test a FIX gateway for our company and was wondering if anything
I have two arrays which contain objects of assets, now I want to subtract
I have written method which should return string with data from select query, but
How should I test a service method that is transactional for its simultaneous use

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.