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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:21:46+00:00 2026-06-13T23:21:46+00:00

I am attempting to write some unit tests for some Ada code I recently

  • 0

I am attempting to write some unit tests for some Ada code I recently wrote, I have a particular case where I am expecting to get an Exception (if the code worked correctly I wouldn’t but in this case all I’m doing is testing, not writing code). If I handle the exception in the Testing routine then I don’t see how I can continue testing in that procedure.

I.E. (This is very much an example and NOT compilable code)

procedure Test_Function is
begin
  from -20 to 20
     Result := SQRT(i);

 if Result = (Expected) then
     print "Passed";
 end_if;

exception:
  print "FAILED";
end Test_Function

My first thought is if I had a “deeper function” which actually did the call and the exception returned through that.

I.E. (This is very much an example and NOT compilable code)

procedure Test_Function is
begin
  from -20 to 20
     Result := my_SQRT(i);

 if Result = (Expected) then
     print "Passed";
 end_if;

exception:
  print "FAILED";
end Test_Function

function my_SQRT(integer) return Integer is
begin
   return SQRT(i);
exception:
   return -1;
end my_SQRT;

And in theory I expect that would work, I just hate to have to keep writing sub functions when my test_function, is expected to do the actual testing.

Is there a way to continue execution after hitting the exception IN Test_Function, rather than having to write a wrapper function and calling through that?
OR
Is there a easier/better way to handle this kind of scenario?

*Sorry for the poor code example, but I think the idea should be clear, if not I’ll re-write the code.

  • 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-13T23:21:47+00:00Added an answer on June 13, 2026 at 11:21 pm

    You can add a block inside the loop.
    Using your pseudo-syntax, it will look something like:

    procedure Test_Function is
    begin
      from -20 to 20
        begin
          Result := SQRT(i);
    
          if Result = (Expected) then
             print "Passed";
          end_if;
    
        exception:
          print "FAILED";
        end;
      end loop;
    end Test_Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to write some unit tests using EasyMock and TestNG and have run
I am attempting to write some simple code in F#, and i get this
I am attempting to write some code that will expediently process video frames. I
I am attempting to write some tests using webtest to test out my python
I am attempting to write some jQuery code that will expand a paragraph when
I am attempting to write some JUnit tests for my android application. The application
I am attempting to write some Java code that takes an image from a
I am attempting to write some code to read in a *.CSPROJ file using
I am attempting to write a two-pass algorithm incorporating some legacy code. I want
I'm attempting to write some tests using the built-in android Junit testing framework. I

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.