Isn't a test for cointegration the same as testing for heteroskedasticity in the residual error terms? Testing for cointegration tests to see if the residuals from a regression between the two variables is a stationary process. So wouldn't a test on those residuals for heteroskedasticity be the same thing? To detect if the variance of the errors is stable and the error terms are not a random walk? Wouldn't a White test or Breusch-Pagan test for heteroskedasticity be the same as an Augmented Dickey-Fuller test? Both would detect if the errors are getting bigger or have a constant variance, right? An increasing variance would imply a random walk and unit root, correct?
 A: There isn't much of a resemblance among the stated tests of heteroskedasticity and the cointegration tests, except that you are regressing functions of residuals on other functions of the regressors and the residuals -- but that isn't really saying a lot, as vast number of tests fit that description. 
Tests of heteroskedasticity
Consider the linear regression model 
$$
Y_i = \boldsymbol{X}_i'\boldsymbol{\beta} + \varepsilon_i
$$
Based on this regression model there are several regression-based tests of heteroskedasticity -- equivalent test statistics that are not regression-based do exist, but those obviate the comparisons that we are after.
Breusch-Pagan
The Breusch-Pagan test of heteroskedasticity has the following steps:


*

*Estimate the regression model above using OLS, and get the residuals $\widehat{\varepsilon}_i$, and the standard error of regression, $\widehat{\sigma}^2 =\tfrac{\sum_{i=1}^n\widehat{\varepsilon}_i^2}{n}$.

*Then, estimate the following auxiliary regression by OLS -- a regression of the standardized residuals on the cross-products of the included regressors.
$$
\boxed{\frac{\widehat{\varepsilon}_i^2}{\widehat{\sigma}^2} = \text{vech}(\boldsymbol{X}_i\otimes\boldsymbol{X}_i')'\boldsymbol{\gamma}+\nu_i}
$$ 


*

*The test statistic here is $\tfrac{1}{2}ESS$, which is distributed $\chi^2_{K+\tfrac{K(K+1)}{2}}$, where there are $K$ regressors in the model.


White


*

*The White test is based on a regression that looks very similar to the one employed by BP


$$
\boxed{\widehat{\varepsilon}_i^2 = \text{vech}(\boldsymbol{X}_i\otimes\boldsymbol{X}_i')'\boldsymbol{\gamma}+\nu_i}
$$ 


*

*The test statistic here is $nR^2$ which is again distributed $\chi^2_{K+\tfrac{K(K+1)}{2}}$.


Aside: Equivalence of a modified version of BP and White
You would not be mistaken in thinking that there exists a version of the BP test that is exactly equivalent to the White test (which is robust to departures of the residuals from normality). This is discussed in Waldman (1983).
Tests of cointegration
Now consider the Engle-Granger two-step residual-based tests of cointegration. 


*

*Here, the model is


$$
Y_{1t} = \beta_0 + \boldsymbol{Y}_{2t}'\boldsymbol{\beta} +\varepsilon_{1t}
$$ 
Again, we fit the regresion model using OLS, and get the estimated residuals, $\widehat{\varepsilon}_{1t}$. 


*

*We now conduct an ADF unit root test on these residuals, that is, we fit the regression
$$
\boxed{\Delta \widehat{\varepsilon}_{1t} = \beta_0 + \gamma \widehat{\varepsilon}_{1t-1} + \sum_{j=1}^p\gamma_j \Delta \widehat{\varepsilon}_{1t-j} +\nu_t}
$$
and conduct a t-test of the regression coefficient $\gamma=0$ using the Engle-Yoo critical values.


Bottomline
The heteroskedasticity tests regress squares of fitted residuals on regressors, and cointegration tests regress differences of fitted residuals on lags and lags of differences of those residuals (compare the three boxed regressions).
Every model has certain features, each of which can be exploited to form tests of that model. For unit root models, the ADF tests use the specific feature in a specific model -- $\rho=1$ in an autoregressive model -- to test for unit roots. There are other tests, for example, the variance ratio tests that exploit the increasing variance aspect of unit roots. They are all, as you can imagine, related. 
