diff --git a/locust/test/test_web.py b/locust/test/test_web.py index 80f9cd7e87..b660555528 100644 --- a/locust/test/test_web.py +++ b/locust/test/test_web.py @@ -348,6 +348,9 @@ def t(self): self.assertEqual(self.environment.host, "https://localhost") self.assertListEqual(["User1", "User2"], response.json()["user_classes"]) + self.assertIsNotNone(self.environment.locustfile, 'verify locustfile is not empty') + self.assertEqual(self.environment.locustfile, "User1,User2", "Verify locustfile variable used in web ui title") + # stop gevent.sleep(1) response = requests.get("http://127.0.0.1:%i/stop" % self.web_port) diff --git a/locust/web.py b/locust/web.py index 17eb11c22e..c692099a7a 100644 --- a/locust/web.py +++ b/locust/web.py @@ -555,6 +555,9 @@ def _update_shape_class(self, shape_class_name): def _update_user_classes(self, user_classes): self.environment.user_classes = list(user_classes.values()) + # populate the locustfile which used in web ui title only + if self.environment.locustfile is None: + self.environment.locustfile = ",".join(self.environment.user_classes_by_name.keys()) # Validating UserClasses self.environment._remove_user_classes_with_weight_zero()