Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update code templates using AAA #145

Closed
PhilippSalvisberg opened this issue Feb 25, 2022 · 0 comments · Fixed by #152
Closed

Update code templates using AAA #145

PhilippSalvisberg opened this issue Feb 25, 2022 · 0 comments · Fixed by #152
Assignees
Milestone

Comments

@PhilippSalvisberg
Copy link
Member

The current code template for the PL/SQL package body looks like this (test_ is the default prefix):

CREATE OR REPLACE PACKAGE BODY test_[package_name] IS

   --
   -- test
   --
   PROCEDURE [procedure_name] IS
      l_actual   INTEGER := 0;
      l_expected INTEGER := 1;
   BEGIN
      -- populate actual
      -- ...
   
      -- populate expected
      -- ...
   
      -- assert
      ut.expect(l_actual).to_equal(l_expected);
   END [procedure_name];

END test_[package_name];
/

The body is grouped into three steps. Firstly, populate actual. Secondly, populate expected. Thirdly, assert.

Instead of these three steps the Arrange-Act-Assert pattern should be used. It's popular in Unit testing.

The new template should look like this:

create or replace package body test_[package_name] is

   --
   -- test
   --
   procedure [procedure_name] is
      l_actual   integer := 0;
      l_expected integer := 1;
   begin
      -- arrange
      -- ...
      
      -- act
      -- ...
   
      -- assert
      ut.expect(l_actual).to_equal(l_expected);
   end [procedure_name];

end test_[package_name];
/

The other template should be changed accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant