diff --git a/tests/peek/ndnpeek.t.cpp b/tests/peek/ndnpeek.t.cpp
new file mode 100644
index 0000000..672875a
--- /dev/null
+++ b/tests/peek/ndnpeek.t.cpp
@@ -0,0 +1,300 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014-2016,  Arizona Board of Regents.
+ *
+ * This file is part of ndn-tools (Named Data Networking Essential Tools).
+ * See AUTHORS.md for complete list of ndn-tools authors and contributors.
+ *
+ * ndn-tools is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ndn-tools, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "tools/peek/ndnpeek/ndnpeek.hpp"
+
+#include "tests/test-common.hpp"
+#include <ndn-cxx/util/dummy-client-face.hpp>
+
+#include <boost/mpl/vector.hpp>
+
+namespace ndn {
+namespace peek {
+namespace tests {
+
+using namespace ndn::tests;
+using boost::test_tools::output_test_stream;
+
+class CoutRedirector : noncopyable
+{
+public:
+  explicit
+  CoutRedirector(std::ostream& destination)
+  {
+    m_originalBuf = std::cout.rdbuf(destination.rdbuf());
+  }
+
+  ~CoutRedirector()
+  {
+    std::cout.rdbuf(m_originalBuf);
+  }
+
+private:
+  std::streambuf* m_originalBuf;
+};
+
+class NdnPeekFixture : public UnitTestTimeFixture
+{
+protected:
+  NdnPeekFixture()
+    : face(io)
+  {
+  }
+
+  void
+  initialize(const PeekOptions& opts)
+  {
+    peek = make_unique<NdnPeek>(face, opts);
+  }
+
+protected:
+  boost::asio::io_service io;
+  ndn::util::DummyClientFace face;
+  output_test_stream output;
+  unique_ptr<NdnPeek> peek;
+};
+
+static PeekOptions
+makeDefaultOptions()
+{
+  PeekOptions opt;
+  opt.prefix = "ndn:/peek/test";
+  opt.minSuffixComponents = -1;
+  opt.maxSuffixComponents = -1;
+  opt.interestLifetime = DEFAULT_INTEREST_LIFETIME;
+  opt.timeout = time::milliseconds(200);
+  opt.link = nullptr;
+  opt.isVerbose = false;
+  opt.mustBeFresh = false;
+  opt.wantRightmostChild = false;
+  opt.wantPayloadOnly = false;
+  return opt;
+}
+
+class OutputFull
+{
+public:
+  static PeekOptions
+  makeOptions()
+  {
+    return makeDefaultOptions();
+  }
+
+  static void
+  checkOutput(output_test_stream& output, const Data& data)
+  {
+    const Block& block = data.wireEncode();
+    std::string expected(reinterpret_cast<const char*>(block.wire()), block.size());
+    BOOST_CHECK(output.is_equal(expected));
+  }
+
+  static void
+  checkOutput(output_test_stream& output, const lp::Nack& nack)
+  {
+    const Block& block = nack.getHeader().wireEncode();
+    std::string expected(reinterpret_cast<const char*>(block.wire()), block.size());
+    BOOST_CHECK(output.is_equal(expected));
+  }
+};
+
+class OutputPayloadOnly
+{
+public:
+  static PeekOptions
+  makeOptions()
+  {
+    PeekOptions opt = makeDefaultOptions();
+    opt.wantPayloadOnly = true;
+    return opt;
+  }
+
+  static void
+  checkOutput(output_test_stream& output, const Data& data)
+  {
+    const Block& block = data.getContent();
+    std::string expected(reinterpret_cast<const char*>(block.value()), block.value_size());
+    BOOST_CHECK(output.is_equal(expected));
+  }
+
+  static void
+  checkOutput(output_test_stream& output, const lp::Nack& nack)
+  {
+    std::string expected = boost::lexical_cast<std::string>(nack.getReason()) + '\n';
+    BOOST_CHECK(output.is_equal(expected));
+  }
+};
+
+BOOST_AUTO_TEST_SUITE(Peek)
+BOOST_FIXTURE_TEST_SUITE(TestNdnPeek, NdnPeekFixture)
+
+using OutputChecks = boost::mpl::vector<OutputFull, OutputPayloadOnly>;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(Default, OutputCheck, OutputChecks)
+{
+  auto options = OutputCheck::makeOptions();
+  initialize(options);
+
+  auto data = makeData(options.prefix);
+  std::string payload = "NdnPeekTest";
+  data->setContent(reinterpret_cast<const uint8_t*>(payload.data()), payload.size());
+
+  {
+    CoutRedirector redir(output);
+    peek->start();
+    this->advanceClocks(io, time::milliseconds(25), 4);
+    face.receive(*data);
+  }
+
+  OutputCheck::checkOutput(output, *data);
+  BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
+  BOOST_CHECK_EQUAL(face.sentInterests.back().getMaxSuffixComponents(), -1);
+  BOOST_CHECK_EQUAL(face.sentInterests.back().getMinSuffixComponents(), -1);
+  BOOST_CHECK_EQUAL(face.sentInterests.back().getInterestLifetime(), DEFAULT_INTEREST_LIFETIME);
+  BOOST_CHECK_EQUAL(face.sentInterests.back().hasLink(), false);
+  BOOST_CHECK_EQUAL(face.sentInterests.back().getMustBeFresh(), false);
+  BOOST_CHECK_EQUAL(face.sentInterests.back().getChildSelector(), -1);
+  BOOST_CHECK(peek->getResultCode() == ResultCode::DATA);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(Selectors, OutputCheck, OutputChecks)
+{
+  auto options = OutputCheck::makeOptions();
+  options.minSuffixComponents = 1;
+  options.maxSuffixComponents = 1;
+  options.interestLifetime = time::milliseconds(200);
+  options.link = makeLink("/net/ndnsim", {{10, "/telia/terabits"}, {20, "/ucla/cs"}});
+  options.mustBeFresh = true;
+  options.wantRightmostChild = true;
+  initialize(options);
+
+  auto data = makeData(options.prefix);
+  std::string payload = "NdnPeekTest";
+  data->setContent(reinterpret_cast<const uint8_t*>(payload.data()), payload.size());
+
+  {
+    CoutRedirector redir(output);
+    peek->start();
+    this->advanceClocks(io, time::milliseconds(25), 4);
+    face.receive(*data);
+  }
+
+  OutputCheck::checkOutput(output, *data);
+  BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
+  BOOST_CHECK_EQUAL(face.sentInterests.back().getMaxSuffixComponents(), 1);
+  BOOST_CHECK_EQUAL(face.sentInterests.back().getMinSuffixComponents(), 1);
+  BOOST_CHECK_EQUAL(face.sentInterests.back().getInterestLifetime(), time::milliseconds(200));
+  BOOST_CHECK_EQUAL(face.sentInterests.back().hasLink(), true);
+  BOOST_CHECK_EQUAL(face.sentInterests.back().getLink(), *options.link);
+  BOOST_CHECK_EQUAL(face.sentInterests.back().getMustBeFresh(), true);
+  BOOST_CHECK_EQUAL(face.sentInterests.back().getChildSelector(), true);
+  BOOST_CHECK(peek->getResultCode() == ResultCode::DATA);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ReceiveNackWithReason, OutputCheck, OutputChecks)
+{
+  auto options = OutputCheck::makeOptions();
+  initialize(options);
+  lp::Nack nack;
+
+  {
+    CoutRedirector redir(output);
+    peek->start();
+    this->advanceClocks(io, time::milliseconds(25), 4);
+    nack = makeNack(face.sentInterests.at(0), lp::NackReason::NO_ROUTE);
+    face.receive(nack);
+  }
+
+  OutputCheck::checkOutput(output, nack);
+  BOOST_CHECK_EQUAL(face.sentInterests.size(), 1);
+  BOOST_CHECK(peek->getResultCode() == ResultCode::NACK);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ReceiveNackWithoutReason, OutputCheck, OutputChecks)
+{
+  auto options = OutputCheck::makeOptions();
+  initialize(options);
+  lp::Nack nack;
+
+  {
+    CoutRedirector redir(output);
+    peek->start();
+    this->advanceClocks(io, time::milliseconds(25), 4);
+    nack = makeNack(face.sentInterests.at(0), lp::NackReason::NONE);
+    face.receive(nack);
+  }
+
+  OutputCheck::checkOutput(output, nack);
+  BOOST_CHECK_EQUAL(face.sentInterests.size(), 1);
+  BOOST_CHECK_EQUAL(face.sentData.size(), 0);
+  BOOST_CHECK_EQUAL(face.sentNacks.size(), 0);
+  BOOST_CHECK(peek->getResultCode() == ResultCode::NACK);
+}
+
+BOOST_AUTO_TEST_CASE(TimeoutDefault)
+{
+  auto options = makeDefaultOptions();
+  initialize(options);
+
+  BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 0);
+
+  peek->start();
+  this->advanceClocks(io, time::milliseconds(25), 4);
+
+  BOOST_CHECK_EQUAL(face.sentInterests.size(), 1);
+  BOOST_CHECK(peek->getResultCode() == ResultCode::TIMEOUT);
+}
+
+BOOST_AUTO_TEST_CASE(TimeoutLessThanLifetime)
+{
+  auto options = makeDefaultOptions();
+  options.interestLifetime = time::milliseconds(200);
+  options.timeout = time::milliseconds(100);
+  initialize(options);
+
+  BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 0);
+
+  peek->start();
+  this->advanceClocks(io, time::milliseconds(25), 8);
+
+  BOOST_CHECK_EQUAL(face.sentInterests.size(), 1);
+  BOOST_CHECK(peek->getResultCode() == ResultCode::TIMEOUT);
+}
+
+BOOST_AUTO_TEST_CASE(TimeoutGreaterThanLifetime)
+{
+  auto options = makeDefaultOptions();
+  options.interestLifetime = time::milliseconds(50);
+  options.timeout = time::milliseconds(200);
+  initialize(options);
+
+  BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 0);
+
+  peek->start();
+  this->advanceClocks(io, time::milliseconds(25), 4);
+
+  BOOST_CHECK_EQUAL(face.sentInterests.size(), 1);
+  BOOST_CHECK(peek->getResultCode() == ResultCode::TIMEOUT);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestNdnPeek
+BOOST_AUTO_TEST_SUITE_END() // Peek
+
+} // namespace tests
+} // namespace peek
+} // namespace ndn
