1
votes

I am using protractor for e2e testing, and I am new to protractor. I am testing a specific library for different scenarios, and for all of those scenarios I need to create a test page. I am thinking of automating that process. My question is: Is there a possibility to inject different permutations of a script to create all of my test pages automatically?

Example:

I want to comment and uncomment the flexible codes for different test pages and create all the permutations possible as: 1)comment both codes(00), 2)comment code1and uncomment code2 (01)), 3)uncomment code1 and comment code2e (10), 4) uncomment both of them (11). I also have different div templates that I want them to exists and not exists in each page in a way that covers all the permutations of their existence together.

<!DOCTYPE HTML>
<html lang="en-us">
<head>
<script>
fixed statement;   

//flexible code1;
flexible code2;
</script>
</head>
<body>

<div id="div1">
<script>
fixed code;
flexible code3;
flexible code4;
</script>
</div>

</body>
</html>
1
you are testing a js library with protractor? as far as I know, it is supposed to be used to test angularjs apps (on html pages)... additionally, testing every single e2e scenario will leave you with a nightmare to maintain... check these out: googletesting.blogspot.com.ar/2015/04/… blog.thecodewhisperer.com/permalink/integrated-tests-are-a-scam - germanio
It is e2e testing, the users to this library product are developers, so we are testing if different scenarios of using the library is working as it is expected. it is not unit testing, it is e2e, looking at the library as a black box and see if it gives you the expected behaviour when is used by develoeprs. - Andisheh Keikha
Also the library is going to change time to time to accept new requierments from customers (developers) so if there is no e2e tests for it, it will be a nightmare to have a lot of testers test it manually after each change. - Andisheh Keikha
Yeah, without unit tests will be veeery hard to keep up with the changes. I am wondering if you could use a grunt task to create those temp html files from, lets say, a template. Then run the protractor specs, and finally delete the temp files and show the results. - germanio
@germanio or maybe you can put your comment as an answer if you think it might be useful to others. - Andisheh Keikha

1 Answers

1
votes

So, to sum up what we discussed in the comments, what it will be better to do for your E2E tests instead of having protractor modify your html/js, is to use a grunt task to create html "temp" files from a template, so you can:

  1. define the scenarios you want
  2. let grunt create the html files
  3. then run protractor against those files, and finally
  4. delete all the temp files and show the results.

You can probably use something like this to do what you have in mind.

But be careful, you do not want to turn a good E2E effort into a maintenance nightmare. Please check these posts about automation testing and how (not) to do it: this one from Google and this one too, which I found very good.