It is quite obvious that if a map is a homotopy equivalence, then its mapping cone is contractible, but is the converse true: mapping cone contractible => the map is a homotopy equivalence? I am thinking about both the topological category and the category of chain complexes.

4$\begingroup$ The mapping cylinder of $f:X\to Y$ is homotopy equivalent to $Y$. The mapping cone is contractible if (but not only if) $f$ is a homotopy equivalence. If $f$ is nullhomotopic then the mapping cone is homotopy equivalent to $Y\vee\Sigma X$. $\endgroup$ – Tom Goodwillie Aug 25 '11 at 18:38

2$\begingroup$ It looks like maybe you made a typo when asking your question. My guess would be you switched "cylinder" for "cone" and "null homotopy" for "homotopy equivalence" ? I frequently say "cone" when I mean "cylinder" and I don't know why. $\endgroup$ – Ryan Budney Aug 25 '11 at 19:39

$\begingroup$ Thanks to Tom and Ryan for corrections. Sure I meant a completely different thing when asking my question; I meant mapping cone and I meant a homotopy equivalence. I am curious to see an example of a map which is not a homotopy equivalence, but its mapping cone is contractible. Especially in the category of chain complexes. Notice that a map is a quasiisomorphism iff its mapping cone is acyclic. $\endgroup$ – Victor Aug 25 '11 at 20:09

2$\begingroup$ Note that to get such an example you need to stay away from differential objects (i.e. $A$ with $d:A\rightarrow A$ s.t. $d\circ d = 0$) since for those $f$ is a homotopy equivalence iff the mapping cone is contractible. See: books.google.com/… $\endgroup$ – David White Aug 25 '11 at 20:55

1$\begingroup$ Another comment: if you end up getting an example from topology, stay away from the case when $X$ and $Y$ are simply connected CW complexes. According to exercise 9 in section 4.2 of Hatcher, that's a case where the mapping cone being contractible implies the map is a homotopy equivalence $\endgroup$ – David White Aug 25 '11 at 21:07
Ok, going off my second comment from above, in exercise 9 from section 4.2 Hatcher gives a hint that solves your problem. Let $X$ be an acyclic CWcomplex which isn’t contractible (I'll give an example below to be complete). Let $f: X \rightarrow *$. The mapping cone of this is $SX$, the suspension of $X$. Exercise 8 of section 4.2 proves that $SX$ is contractible because $X$ is acyclic. But the map $X \rightarrow *$ is not a homotopy equivalence.
Solution to Exercise 8: Suppose $\tilde{H}_*(X)=0$. From $H_0$ we see $X$ is path connected, so $SX$ is simply connected. Thus $H_* (SX) = 0 $ . By the Hurewicz theorem $\pi_*(SX)=0$ so $SX$ is contractible as desired.
An acyclic CWcomplex which is not contractible (thanks to link)... Let $a$ and $b$ be the two loops in $X=S^1 \vee S^1$. Glue in two 2cells along the words $a^5b^{3}$ and $b^3(ab)^{2}$. Then $\pi_1(X) = \langle a,ba^5b^{3},b^3(ab)^{2}\rangle$ and this surjects onto the symmetry group of a regular dodecahedron (so $\pi_1(X)\not \cong 0$) while $H_1(X)$ is trivial because it's the abelianization and playing with symbols lets you reduce those relations to $H_1(X) \cong \langle a,b  a,b\rangle \cong 0$. It's clear that $H_n(X)\cong 0$ for $n>1$ because of the dimensions of the cells involved.

$\begingroup$ sorry, is the space $X$ from this example $K(\pi, 1)$? $\endgroup$ – Andrey Ryabichev Jan 6 '16 at 13:55
The accepted answer addresses the version of the question for topological spaces. But there is also a positive result for triangulated categories: a morphism $f \colon X \to Y$ is an isomorphism if and only if any distinguished triangle $X \to Y \to Z \to X[1]$ has $Z \cong 0$. See Tag 05QR.
This in particular applies to the homotopy category $K(\mathcal A)$ of chain complexes with values in an additive category $\mathcal A$, which is a triangulated category by Tag 014S. Applying this to the mapping cone in $K(\mathcal A)$ shows that $C(f)$ is contractible if and only if $f$ is a homotopy equivalence.
This also applies to the stable homotopy category of spectra, where it implies that a map of topological spaces $f \colon X \to Y$ with contractible mapping cone is a stable homotopy equivalence.
In examples like David White's answer, you only need to go up to the first suspension $\Sigma X$, by construction (but see also this answer). I'm not sure if something like this is supposed to be true in general, but I'm guessing it's more complicated.
Weibel: An Introduction to Homological Algebra, Exercise 1.5.10 (1994 edition) asks you to show that for $C,C'$ split complexes with splittings $s,s'$ the cone on a map $f: C \to C'$ is split by the map $(c,c') \mapsto (s(c),s'(c')s'fs(c))$ if and only if the induced map on homology $H(f): H(C) \to H(C')$ is zero.