How are testing schemas used via PgTAP?

I am using PgTAP for our PostgreSQL unit testing framework. I understand the fundamentals of its operation and have written several tests successfully.

I would like to leverage the ability to create formal testing "schemas" however, as the example from this blog describes:


We create our schema:

CREATE SCHEMA unit_testing;

TEST=# CREATE OR REPLACE FUNCTION unit_testing.setup_tap_test_example() 
RETURNS SETOF TEXT AS $$
BEGIN
    INSERT INTO public.table1 VALUES ('test',1);
    RETURN NEXT is(a, 'TEST', 'Should have initial row in table1') FROM public.table1 WHERE b = 1;
END;
$$ LANGUAGE plpgsql;

TEST=# CREATE OR REPLACE FUNCTION unit_testing.tap_test_example() 
RETURNS SETOF TEXT AS $$
BEGIN
    RETURN NEXT has_table('public', 'table1', 'table public.table1 exists' );
    RETURN NEXT has_column('public', 'table1', 'a', 'column public.table1.a exists');
    RETURN NEXT col_type_is('public', 'table1', 'a', 'text', 'Type of column public.table1.a is text');
    RETURN NEXT has_column('public', 'table1', 'b', 'column public.table1.b exists');
    RETURN NEXT col_type_is('public', 'table1', 'b', 'integer', 'Type of column public.table1.b is integer');
    RETURN NEXT has_index('public', 'table1','table1_b_idx', 'Table public.table1 has an index table1_b_idx');
END;
$$ LANGUAGE plpgsql;

TEST=# CREATE OR REPLACE FUNCTION unit_testing.teardown_tap_test_example() 
RETURNS SETOF TEXT AS $$
BEGIN
    RETURN NEXT lives_ok('DELETE FROM public.table1 WHERE b = 1');
END;
$$ LANGUAGE plpgsql;

then run it:

TEST=# BEGIN;
TEST=# SELECT * FROM runtests('unit_testing','^tap_test_example');
ok 1 - Should have initial row in table1
# unit_testing.tap_test_example()
ok 2 - table public.table1 exists
ok 3 - column public.table1.a exists
ok 4 - Type of column public.table1.a is text
ok 5 - column public.table1.b exists
ok 6 - Type of column public.table1.b is integer
ok 7 - Table public.table1 has an index table1_b_idx
ok 8
1..8
TEST=# ROLLBACK;

My question is: are we running the first script block in the same script as the second? This would make sense as we would have to ensure the schema/functions exist before invoking them. Could we also split our "schema/function creation" scripts and "test execution scripts" into multiple files for modularity? If so, how can we ensure that when we invoke pg_prove that we're executing the creation script(s) before the execution script(s)? Or am I misunderstanding the relationship between these actions? Thank you!