Q:

How to declare a new environment similar to abstract in a report?

Similar questions have been asked, but none have answered my particular problem.
I am trying to declare in a report a new environment which would be similar to the abstract environment. I have looked at the code in report.cls and found the definition for the abstract environment:
\if@titlepage
  \newenvironment{abstract}{%
      \titlepage
      \null\vfil
      \@beginparpenalty\@lowpenalty
      \begin{center}%
        \bfseries \abstractname
        \@endparpenalty\@M
      \end{center}}%
     {\par\vfil\null\endtitlepage}
\else
  \newenvironment{abstract}{%
      \if@twocolumn
        \section*{\abstractname}%
      \else
        \small
        \begin{center}%
          {\bfseries \abstractname\vspace{-.5em}\vspace{\z@}}%
        \end{center}%
        \quotation
      \fi}
      {\if@twocolumn\else\endquotation\fi}
\fi

In my document I have declared the test environment in the same fashion, and used it as I would use abstract:
\documentclass[]{report}

\newcommand\testname{Test}

\newenvironment{test}{%
    \small
    \begin{center}%
        {\bfseries \testname\vspace{-.5em}\vspace{\z@}}%
    \end{center}%
    \quotation}
    {\endquotation}

\begin{document}

\begin{test}
Test
\end{test}

\end{document}

This results in the following error:
./test.tex:15: Undefined control sequence. [\begin{test}]
./test.tex:15: Missing number, treated as zero. [\begin{test}]
If you can't figure out why I needed to see a number,:15: Illegal unit of measure . [\begin{test}]

I understand the problem comes from the \z@ but I understand neither why nor how to fix this.

A:

Since the definition involves the @ character (with category code 12), you need to enclose it between \makeatletter, \makeatother to change its category code to 11 during the definition, and back to 12 after the definition:
\documentclass[]{report}

\newcommand\testname{Test}

\makeatletter
\newenvironment{test}{%
    \small
    \begin{center}%
        {\bfseries \testname\vspace{-.5em}\vspace{\z@}}%
    \end{center}%
    \quotation}
    {\endquotation}
\makeatother

\begin{document}

\begin{test}
Test
\end{test}

\end{document}

If insetad of \z@ you use 0pt, you don't need \makeatletter, \makeatother:
\documentclass[]{report}

\newcommand\testname{Test}

\newenvironment{test}{%
    \small
    \begin{center}%
        {\bfseries \testname\vspace{-.5em}\vspace{0pt}}%
    \end{center}%
    \quotation}
    {\endquotation}

\begin{document}

\begin{test}
Test
\end{test}

\end{document}

However, a simpler approach would be to say:
\documentclass[]{report}

\newcommand\testname{Test}
\newenvironment{test}
  {\renewcommand\abstractname{\testname}\begin{abstract}}
  {\end{abstract}}

\begin{document}

\begin{test}
Test
\end{test}

\end{document}

