This paper presents an experience in developing professional ethics by an approach that integrates knowledge, teaching methodologies and assessment coherently. It has been implemented for students in both the Software Engineering and Computer Engineering degree programs of the Technical University of Madrid, in which professional ethics is studied as a part of a required course. Our contribution of this paper is a model for formative assessment that clarifies the learning goals, enhances the results, simplifies the scoring and can be replicated in other contexts. A quasi-experimental study that involves many of the students of the required course has been developed. To test the effectiveness of the teaching process, the analysis of ethical dilemmas and the use of deontological codes have been integrated, and a scoring rubric has been designed. Currently, this model is also being used to develop skills related to social responsibility and sustainability for undergraduate and postgraduate students of diverse academic context.