I'm making here also assumption that this feature is free.
DB Feature is free but not available on SE (XE/FREE? yes)... oh, and only for 12c+.
Within my fork+branch, I'm trying to ensure base code can still compile on 11g and SE by keeping all RAS related code as an "optional install". Your platform doesn't support RAS? don't install/use that code. (Also, there are some setup things that can't be done as ADMIN - the initial ADB DBA account on OCI).
The core RAS Session management code I have is its own type that can be called within the test procedure body (ie the simpler way). Every test can use a different session with different settings (roles, context) that are persisted between attach_session calls of the same sessionid;
Why can't this be simple beforeall and afterall procedures depending on requirements on suite, context or procedure?
I'm still exploring this option myself.
The problem I see right off is: I don't think you have a --%finalize annotation that I can use to ensure that the DB session is detached and destroy_session is called for all created sessions at the end of a test run, even if errors have occurred.
One theoretical problem I'm keeping an eye on is if usage of RAS (in your suggested pattern) will interfere with currently available reporters. Worst case scenario: in order to avoid any side effects, the SQL statement used by dbms_sql.parse would need to include the attach/detach_session calls. I'm hoping to avoid this too.
Oh .. and transaction control (--%rollback()) might go out the window due to the statelessness of RAS Sessions. Whoever calls detach_session may need to know whether to set the first parameter as TRUE (rollback) or FALSE (commit - default)..
Context information is definitely "lost" when you attach_session; a list of attributes is needed to future-proof the copying of sys_context values to a Namespace (xs_sys_context). That list is also needed for when the installer creates the Namespace (RAS version of Context) in the first place. note I'm improving the code I have ATM to be more 11g/SE friendly.