This article aims to propose a new approach to the empirical testing of the pecking order theory that tackles commonly reported issues and apply it to the analysis of Brazilian companies. The main gaps bridged herein are the lack of clear definitions for safe debt and financial slack; the lack of control, in regressions, for the financing sources’ capabilities; and the failure to consider future investment opportunities in financing analyses. We adopt methods that enable controlling for the information the companies have about each financing source’s capabilities, at the time their financing decisions are made, while taking current and future investment opportunities into account. The proposed methodology offers a rather controlled environment to test the pecking order theory, which can be adapted to study other topics in finance, supporting advances in understanding the raising and allocation of funds by listed companies. Four integrated financing and cash holding policies are defined, which lead to different expected internal deficits (or surpluses). The relationships between these deficits (or surpluses), at different levels, and the flows that are observed at the external sources of funds are analyzed in cross-section and panel data quantile regressions, controlling for each source’s capabilities, in unbalanced data panels with 4,465 observations of 223 companies. By studying the relationships between expected internal financing deficits (or surpluses) and the flows that are observed at the external sources of funds, we contribute with a new capital structure testing methodology, and we find strong evidence that Brazilian listed companies follow the pecking order theory.