Q:

Text above line in tikz

I have drawn some block elements with tikz and named them A and B.
I am trying to draw a line between them with
\path [line] (requested) -- (processing);

but I also want some text above the line.
\path [line] (requested) -- node [above,midway] {Some text} (processing);

works but if the text is very long it just keeps running without breaking the line.
How can I make sure the text wont be wider than the line itself?
Edit
With
\documentclass[tikz]{standalone}

\usetikzlibrary{shapes,arrows,chains}

\begin{document}

\tikzstyle{block} = [rectangle, draw, text width=6em, text centered, rounded corners, minimum height=4em]
\tikzstyle{line} = [draw, -latex']

\begin{tikzpicture}[node distance=1cm, auto]
    \node (init) {};
    \node [block] (A) {A};
    \node [block, right=of A] (B) {B};

    \path [line] (A) -- node [text width=2.5cm,midway,above] {My very looooooong text which is wider than the arrow below} (B);
\end{tikzpicture}

\end{document}

I get

How can I in a smarter way make sure there is room for the text? I have multiple boxes.

A:

two possibilities
- Specifying the distance above
- By separating the blocks
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,chains}
\usetikzlibrary[calc]

\begin{document}

\tikzstyle{block} = [rectangle, draw, text width=6em, text centered, rounded corners, minimum height=4em]
\tikzstyle{line} = [draw, -latex']

\begin{tikzpicture}[node distance=1cm, auto]
\node (init) {};
\node [block] (A) {A};
\node [block, right= of A] (B) {B};

\path [line] (A) -- node [text width=2.5cm,midway,above=3em ] {My very looooooong text which is wider than the arrow below} (B);
\end{tikzpicture}

\begin{tikzpicture}[node distance=1cm, auto]
\node (init) {};
\node [block] (A) {A};
\node [block, right=3cm of A] (B) {B};

\path [line] (A) -- node [text width=2.5cm,midway,above ] {My very looooooong text which is wider than the arrow below} (B);
\end{tikzpicture}

\end{document}

if you want center the text
\documentclass{article}

\usepackage{tikz}

\usetikzlibrary{shapes,arrows,chains}
\usetikzlibrary[calc]

\begin{document}

\tikzstyle{block} = [rectangle, draw, text width=6em, text centered, rounded corners, minimum height=4em]
\tikzstyle{line} = [draw, -latex']

\begin{tikzpicture}[node distance=1cm, auto]
    \node (init) {};
    \node [block] (A) {A};
    \node [block, right= of A] (B) {B};

    \path [line] (A) -- node [text width=2.5cm,midway,above=3em,align=center ] {My very looooooong text which is wider than the arrow below} (B);
\end{tikzpicture}

\begin{tikzpicture}[node distance=1cm, auto]
    \node (init) {};
    \node [block] (A) {A};
    \node [block, right=3cm of A] (B) {B};

    \path [line] (A) -- node [text width=2.5cm,midway,above,align=center ] {My very looooooong text which is wider than the arrow below} (B);
\end{tikzpicture}

\end{document}

A:

As exercise ...
\documentclass[tikz,border=2mm]{standalone}
    \usetikzlibrary{arrows,chains}

\begin{document}
    \begin{tikzpicture}[
 start chain = going right,
block/.style = {rectangle, draw, rounded corners, 
                text width=6em, align=center, minimum height=4em,
                on chain},
every pin/.style = {inner sep=1mm, align=center, font=\footnotesize,
                    pin distance=9mm, pin edge={angle 60-, solid, black}},
                        ]
\node[block] (A) {A};
\node[block] (B) {B};

\linespread{0.9}
    \draw[-latex'] (A) to node[inner sep=0pt,
                                pin=above:My very looooooong\\
                                text which is wider\\
                                than the arrow below] {}    (B);
    \end{tikzpicture}
\end{document}

When is not enough place for text on lines this quit common way to add description of line (meaning). This text is usually smaller than main text. For it I select \footnotesize. I broke it manually, I think that on this way you can easily accommodate his appearances to your taste or to disposable space.

