import logging
 import os
 import time
+
 import json
+import six
 
 from behave.__main__ import main as behave_main
 
                 self.__logger.exception("Cannot create %s", self.res_dir)
                 return self.EX_RUN_ERROR
         config = ['--tags='+','.join(tags),
-                  '--format=json',
-                  '--outfile='+self.json_file]
+                  '--junit', '--junit-directory={}'.format(self.res_dir),
+                  '--format=json', '--outfile={}'.format(self.json_file)]
+        if six.PY3:
+            html_file = os.path.join(self.res_dir, 'output.html')
+            config += ['--format=behave_html_formatter:HTMLFormatter',
+                       '--outfile={}'.format(html_file)]
         for feature in suites:
             config.append(feature)
         self.start_time = time.time()
 
 """Define the classes required to fully cover behave."""
 
 import logging
+import os
 import unittest
 
 import mock
+import six
+
 from xtesting.core import behaveframework
 
 __author__ = "Deepak Chandella <deepak.chandella@orange.com>"
             self.assertEqual(
                 self.test.run(suites=self.suites, tags=self.tags),
                 self.test.EX_OK)
-            args[0].assert_called_once_with(
-                ['--tags=',
-                 '--format=json',
-                 '--outfile={}'.format(self.test.json_file),
-                 'foo'])
+            html_file = os.path.join(self.test.res_dir, 'output.html')
+            args_list = [
+                '--tags=', '--junit',
+                '--junit-directory={}'.format(self.test.res_dir),
+                '--format=json', '--outfile={}'.format(self.test.json_file)]
+            if six.PY3:
+                args_list += [
+                    '--format=behave_html_formatter:HTMLFormatter',
+                    '--outfile={}'.format(html_file)]
+            args_list.append('foo')
+            args[0].assert_called_once_with(args_list)
             mock_method.assert_called_once_with()
 
     @mock.patch('os.makedirs')
             self.test.run(
                 suites=self.suites, tags=self.tags),
             status)
-        args[0].assert_called_once_with(
-            ['--tags=',
-             '--format=json',
-             '--outfile={}'.format(self.test.json_file),
-             'foo'])
+        html_file = os.path.join(self.test.res_dir, 'output.html')
+        args_list = [
+            '--tags=', '--junit',
+            '--junit-directory={}'.format(self.test.res_dir),
+            '--format=json', '--outfile={}'.format(self.test.json_file)]
+        if six.PY3:
+            args_list += [
+                '--format=behave_html_formatter:HTMLFormatter',
+                '--outfile={}'.format(html_file)]
+        args_list.append('foo')
+        args[0].assert_called_once_with(args_list)
         args[1].assert_called_once_with(self.test.res_dir)
 
     def test_parse_results_exc(self):