diff --git a/tests/test_sampleinput.py b/tests/test_sampleinput.py
index c03630f125cf78d3adaf6bb5f5df2a93ce12677e..70d8eea551e31ac6ac6f79ac0ae9a2dc6175c6a7 100644
--- a/tests/test_sampleinput.py
+++ b/tests/test_sampleinput.py
@@ -2,11 +2,20 @@
 
 import pytest
 import pandas as pd
+import os
+import importlib.util
+from pathlib import Path
+import sys
 
-from src.sample_from_input import sample_from_input
+from src.sample_from_input import (
+    sample_from_input,
+    main
+    )
+
+PACKAGE_DIR = Path(__file__).resolve().parents[1] / 'src'
 
 
-def test_sampleinput(tmpdir):
+def test_sample_from_input(tmpdir):
     """Tests the output, input file name and separator."""
     sample_from_input(
         input_file='./tests/resources/Transcript2.tsv',
@@ -14,9 +23,34 @@ def test_sampleinput(tmpdir):
         sep='\t',
         n=142958
     )
-    t1=pd.read_table(tmpdir / 'test1.csv', header=None, sep=',')
-    assert t1[1].sum()==142958
+    t1 = pd.read_table(tmpdir / 'test1.csv', header=None, sep=',')
+    assert t1[1].sum() == 142958
     with pytest.raises(IndexError):
         sample_from_input(input_file='./tests/resources/Transcript2.tsv')
     with pytest.raises(IOError):
         sample_from_input(input_file='file_not_existing.txt')
+
+
+def test_main_with_args(monkeypatch, tmpdir):
+    """Call with args."""
+    monkeypatch.setattr(
+        sys, 'argv', [
+            'sample_from_input',
+            './tests/resources/Transcript1.csv',
+            '-o',
+            str(tmpdir / 'test1.csv'),
+        ]
+    )
+    ret_val = main()
+    assert ret_val is None
+
+
+def test_main_as_script():
+    """Run as script."""
+    main_file = PACKAGE_DIR / "sample_from_input.py"
+    fl = os.path.join(os.path.dirname(__file__), main_file)
+    spec = importlib.util.spec_from_file_location('__main__', fl)
+    module = importlib.util.module_from_spec(spec)
+    with pytest.raises(SystemExit) as exc:
+        spec.loader.exec_module(module)
+    assert exc.value.code != 0
\ No newline at end of file