[proofplan]
We approximate $f \in L^p(\Omega)$ by a test function in two stages: first truncate $f$ to a compact subset of $\Omega$ via dominated convergence, then mollify the truncation to obtain a smooth, compactly supported function. The triangle inequality combines the two approximations.
[/proofplan]
[step:Truncate $f$ to compact support via dominated convergence]
Choose an exhaustion $K_1 \subset K_2 \subset \cdots$ of $\Omega$ by compact sets with $\bigcup_j K_j = \Omega$.
Define $f_j := f \cdot \mathbb{1}_{K_j}$.
Then $f_j \in L^p(\Omega)$, $\mathrm{supp}(f_j) \subseteq K_j$, and
\begin{align*}
|f_j(x) - f(x)|^p &= |f(x)|^p \cdot \mathbb{1}_{\Omega \setminus K_j}(x) \leq |f(x)|^p
\end{align*}
for $\mathcal{L}^n$-a.e. $x$.
The right-hand side is integrable ($f \in L^p$), and $f_j(x) \to f(x)$ a.e. (since $\bigcup_j K_j = \Omega$).
By the [dominated convergence theorem](/theorems/4),
\begin{align*}
\|f_j - f\|_{L^p}^p &= \int_\Omega |f|^p \cdot \mathbb{1}_{\Omega \setminus K_j} \, d\mathcal{L}^n \to 0.
\end{align*}
Fix $j$ large enough that $\|f_j - f\|_{L^p} < \varepsilon/2$.
[/step]
[step:Mollify the truncation to obtain a test function]
Let $\rho \in \mathcal{D}(\mathbb{R}^n)$ be a [standard mollifier](/page/Standard%20Mollifier) and set $\rho_\delta(x) := \delta^{-n}\rho(x/\delta)$.
Extend $f_j$ by zero outside $\Omega$ and define $g_\delta := f_j * \rho_\delta$.
By the [Properties of Mollification](/theorems/461) (property 1), $g_\delta \in C^\infty(\mathbb{R}^n)$.
By property 2, $\mathrm{supp}(g_\delta) \subseteq \mathrm{supp}(f_j) + \overline{B}(0, \delta) \subseteq K_j + \overline{B}(0, \delta)$.
Since $K_j$ is a compact subset of the open set $\Omega$, $\mathrm{dist}(K_j, \partial\Omega) > 0$.
For $\delta < \mathrm{dist}(K_j, \partial\Omega)$, the set $K_j + \overline{B}(0, \delta)$ is a compact subset of $\Omega$, so $g_\delta \in \mathcal{D}(\Omega)$.
By property 3, $\|g_\delta - f_j\|_{L^p} \to 0$ as $\delta \to 0$.
Choose $\delta$ small enough (and less than $\mathrm{dist}(K_j, \partial\Omega)$) so that $\|g_\delta - f_j\|_{L^p} < \varepsilon/2$.
[/step]
[step:Combine the two approximations]
Set $\varphi := g_\delta \in \mathcal{D}(\Omega)$.
The triangle inequality gives
\begin{align*}
\|f - \varphi\|_{L^p} &\leq \|f - f_j\|_{L^p} + \|f_j - g_\delta\|_{L^p} < \frac{\varepsilon}{2} + \frac{\varepsilon}{2} = \varepsilon.
\end{align*}
[/step]